nn.CrossEntropyLoss expects the output tensor to contain the class logits in dim1, while this particular dimension is missing in the target tensor, which contains the class indices.
A vanilla multi-class classification output would therefore be defined as [batch_size, nb_classes], while the target would only be [batch_size].
For a segmentation use case, you could use [batch_size, nb_classes, height, width] for the output and [batch_size, height, width] for the target.
In your example, it seems the temporal dimension was collapsed with the batch size into dim0.