In a classification use case you can pass the raw logits (i.e. the model output without a non-linearity) to nn.CrossEntropyLoss. Internally F.log_softmax and nn.NLLLoss is called.
Alternatively you could add nn.LogSoftmax to out output layer and use nn.NLLLoss as the criterion.
The underscore is used to throw away the returned value. torch.max would return the max value and the corresponding index. As we only need the index, the value is discarded. Alternatively you could also use torch.argmax.