Can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first

You try and call .detach() on something that is already a numpy array as stated in the error.