Whats the error that you are getting?
At the very least you could comeup with something like this :
def visualize_imgs(imgs, labels, row=3, cols=11,):
    imgs = imgs.detach().numpy().transpose(0, 2,3,1)
    # now we need to unnormalize our images. 
    fig = plt.figure(figsize=(20,5))
    for i in range(imgs.shape[0]):
        ax = fig.add_subplot(row, cols, i+1, xticks=[], yticks=[])
        # if your images are 1 channel only, remove the channel dimension
        # so that matplotlib can work with it (e.g. change  28x28x1 to 28x28!)
        # like this ax.imshow(imgs[i].squeeze(), cmap='gray')
        ax.imshow(imgs[i])
        ax.set_title(labels[i].item())
    plt.show()

this should work as well, you may need to change it based on your needs, for example the rows, cols need to be set based on you batchsize. if you have normalized the inputs, unnormalize them as well.