The out of bounds error is thrown if you pass class indices, which are negative (t < 0) or greater or equal to the number of classes (t >= n_classes).
E.g. if you have 5 classes, the class indices shoule be in [0, 4].
Could you check your target tensor for these out of bounds values?
nn.NLLLoss is the negative log likelihood loss which is used in the usual classification use case.
nn.CrossEntropyLoss uses internally a nn.LogSoftmax layer and nn.NLLLoss to calculate the loss.