Based on the error in your notebook it seems the input is not a batch of images, but a single image without the batch dimension.
This issue is most likely created since you are iterating the Dataset instead of the DataLoader:
for inputs, labels in dataloaders[phase].dataset:

Change it to:
for inputs, labels in dataloaders[phase]:

and it should work, since the DataLoader will automatically create the batches.