Check your targets data type using targets.dtype.
If not int64, then convert it to int64 using targets = targets.long()
Or even, when you create the tensor, you do it like this:
targets = torch.tensor([[1,0,0,0,0],[0,1,0,0,0]], dtype=torch.long)