Your problem is likely the dimension of the labels tensor.
In your class MyDataset your y is an array([2]). If you load now these target labels using the dataloader this will output a tensor with an additional dimension which NLLLoss will complain about.
Calling labels.squeeze() before the loss (i.e. loss = criterion(outputs, labels.squeeze())) should fix the error.
Also have a look at this issue which describes a similar problem: #3670 13