nn.CrossEntrolyLoss expects a model output in the shape [batch_size, nb_classes, *additional_dims] and a target in the shape [batch_size, *additional_dims] containing the class indices in the range [0, nb_classes-1].
Based on your output shape it seems you are dealing with 17451 classes and a temporal dimension of 5. The target should thus have a shape of [1, 5] (note the missing channel dimension).
Also, it seems your target might be one-hot encoded, as it’s using the class dimension in dim1, but is missing the temp. dim?
Maybe your use case is vice versa and you are dealing with 5 classes.
In this case, you would have to permute the output so that it has the shape [1, 5, 17451].