The error points to an out of bounds index for nn.NLLLoss (or nn.CrossEntropyLoss):
Assertion `t >= 0 && t < n_classes` failed.

Make sure to pass the target with values in the range [0, nb_classes-1].