data = torch.cat(data, dim=0)

I am pretty sure that
data = torch.tensor(data)

would already do the job here. And here

data = data.cuda()

you can use
data = data.to(device)

where “device” is e.g., a GPU, depending on which one you want. For the first one,
device = torch.device('cuda:0')

Mentioning this because that’s the recommended way since v0.4, although your suggestions would also work fine.