as you see in the comment of the line above the one you highlighted, pred has the index of the max log-probability. Hence, checking pred == target and summing total correct predictions in the mini-batch adds up to total correctly predicted.