I am trying to visualize the images in one batch of the data loader. I got this code snippet from Pytorch official site.
def imshow(inp, title=None):
    """Imshow for Tensor."""
    inp = inp.numpy().transpose((1,2,0))
    print(inp.shape)
    plt.imshow(inp)
    if title is not None:
         plt.title(title)
    # plt.pause(0.001)  # pause a bit so that plots are updated

# Get a batch of training data
image, label = next(iter(train_loader))
print(image.shape)
#print(label)
# Make a grid from batch
out = torchvision.utils.make_grid(image)
imshow(out, title=[label[x] for x in label])

However, I am not able to understand  inp.numpy().transpose((1,2,0)), what transpose is doing here. I know that it permutes the axis. However, the corresponding tensor shape is torch.Size([4, 3, 224, 224]). In that case (1,2,0) corresponds to 3,224,4.  Then how imshow is correctly displaying images?
Apart from that, the shape of the tensor image is 3,224,224. but when it is being transformed to ndarray why the shape is being changed to (228, 906, 3). Should it become 224, 224, 3.