Try this tutorial: https://github.com/pytorch/tutorials/blob/master/beginner_source/blitz/cifar10_tutorial.py 64
I think trainset and testset are each a big tensor. You can run the operations on them that you want.