Solved by sonsus in post #2 
              
              
                For this part what I can tell you is that nn.CrossEntropyLoss() does take output as one-hot encoded and targets with indices that isn’t encoded into one-hot. Internally it converts it into one-hot encoding and computes the loss. 
You can find this easily on documentation and its source code.