Remove the .numpy() operations and pass the tensors to the soft_loss function.
As described before, you won’t be able to call backward() on the loss and calculate gradients with it, since you are also explicitly detaching the tensors, but I assume that’s wanted.