Check documentation for nn.NLLLoss here: https://pytorch.org/docs/stable/nn.html 89. Function is created the way, that is takes class index as an argument for target.
Then it converts class index to 1/0 vector, takes log and compares it with prediction vector.
Comparison is performed.