You could use this approach, if you apply softmax on the output of your model to match the one-hot encoded targets.
This approach should work without code issues, however I’m skeptical, if that’s the best approach for a multi-class classification, since you would usually use cross entropy instead of mseloss.