maybe we need to pass index to second argument of nll loss, which must be of type Long, like,
import torch, torch.nn.functional as F
inp = torch.tensor([[0.1, 0.2, 0.3]])
target = torch.tensor([1])
x = F.nll_loss(inp, target)
x

tensor(-0.2000)