You can save and load tensors via torch.save(tensor, path) and torch.load(tensor, path), respectively. This would allow you to load these tensors afterwards and create the TensorDataset directly without creating the lists.