This could indicate that you have already transformed the tensor to a numpy array and it shouldn’t be a problem anymore.
In case loss is a tensor, check its .grad_fn attribute. If it’s showing a valid function, it’s attached to a computation graph, otherwise it’s detached.