I think my assumption is correct and you would have to make sure all images have the same shape so that the DataLoader can stack them to create a batch.
nn.CrossEntropyLoss expects an output in the shape [batch_size, nb_classes] and a target in [batch_size] containing class indices in the range [0, nb_classes-1] for a multi-classification use case.