The error message suggests to move the tensor to the CPU first in order to transform it into a numpy array:
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.