I'm learing pytorch.Reading the official tutorial,I met the preplexing code. input is a tensor, so is target.
def nll(input,target):
return -input[range(target.shape[0]),target].mean()
And the pred is:

target is:

the '-input[range(target.shape[0]),target]' is:
!['input[range(target.shape[0],target]'](https://i.stack.imgur.com/0gcq9.png)
Output shows this is not substracting target from input or merging two tensors