A manual (and slow) implementation can be found here and the CPU implementation calls into cross_entropy_loss and then into nll_loss.
A manual (and slow) implementation can be found here and the CPU implementation calls into cross_entropy_loss and then into nll_loss.