nn.CrossEntropyLoss expects a model 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-class classification.
Based on the error message I guess your target has an additional dimension, which should be removed.