I am pretty sure it does that implicitly, because while one-hot encoding is nice on paper (mathematically efficiently to express) it must be very inefficient for a computer to do it explicitly. Either way, it does exactly what you’d expect if you’d carry out the one-hot encoding manually (quick demo here: https://github.com/rasbt/stat479-deep-learning-ss19/blob/master/L08_logistic/code/cross-entropy-pytorch.ipynb 1)