torch to numpy with device code example Example: tensor.numpy() pytorch gpu tensor_array.cpu().detach().numpy()