As seen in my code snippet I’m using nn.CrossEntropyLoss since it’s a classification use case.
If you want to use nn.MSELoss for specific reasons, you would have to provide the target in the same shape as the model output, i.e. [batch_size, 10] e.g. by one-hot encoding it.