The following code snippet could help to understand:
def train(train_loader, model, criterion, optimizer, epoch ):
model.train()


losses = AverageMeter()

rows = 2
cols = 2
fig=plt.figure()
axes = []
for idx, (images, labels) in enumerate(train_loader):
    data_time.update(time.time() - end)

                               
  
    print('.........Size of image before unsqueeze : ',images[0].shape)
    b = images[0].reshape(3,32,32)
    npimg = b.numpy()
  
    axes.append( fig.add_subplot(rows, cols, idx+1) )
   
    plt.imshow(npimg)
plt.show()
exit()

The error is: