You are detaching the prediction tensor here:
y_pred1 = y_pred.data.numpy().astype("int")

Don’t use the .data attribute, as it may have unwanted side effects.
Also, once you leave PyTorch and use other libraries such as numpy, Autograd won’t be able to automatically create the backward pass for you, so you would need to implement the backward function manually. Instead pass y_pred directly to your criterion.
For a multi-class classification with nn.CrossEntropyLoss the output of your model should have the shape [batch_size, nb_classes], while the target should be a LongTensor in the shape [batch_size] containing the class indices in the range [0, nb_classes-1].