Plotting the output from Cuda

TypeError: can’t convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Hello friends I am getting this error while plotting my waveform output (predictions) vs targets values, from the cuda as i am training my dataset on cuda gpu thats why its getting me this error I have searched online one of the solution suggested by community is to use

```  but it gives my this error 
"'int' object is not callable"

while this solution  
"outputs = models[0]((inputs).squeeze()).cpu()"
gives me this error

"RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!"

 any other way which can solve the problem

The right approach is to push the tensors to the CPU before trying to call plt.plot on them.
It’s unclear what raises the last error, since it seems you are trying to call .cpu() on the model output, which is not using two different tensors which might create the device mismatch (so I guess the error is raised in another line of code).