nn.CrossEntropyLoss should be a good fit in your case.
You are not really encoding the labels in a hierarchical order as this would be the case using nn.MSELoss.
Instead you provide the class indices, which will be used to get the current class probability. So there is mathematically no difference between this approach and using one-hot encoded tensors.
That being said, nn.CrossEntropyLoss expects class indices and does not take one-hot encoded tensors as target labels.
If you really need to use it for some other reasons, you would probably use .scatter_ to create your one-hot encoded targets.