how to detach list of pytorch tensors to array
There is a list of PyTorch's Tensors and I want to convert it to array but it raised with error:

'list' object has no attribute 'cpu'

How can I convert it to array?
import torch
result = []
for i in range(3):
    x = torch.randn((3, 4, 5))
    result.append(x)
a = result.cpu().detach().numpy()


You can stack them and convert to NumPy array:
import torch
result = [torch.randn((3, 4, 5)) for i in range(3)]
a = torch.stack(result).cpu().detach().numpy()

In this case, a will have the following shape: [3, 3, 4, 5].
If you want to concatenate them in a [3*3, 4, 5] array, then:
a = torch.cat(result).cpu().detach().numpy()

