I think torchvision.datasets.CIFAR10 is not able to accept a list of indices out of the box, as this code 6 would try to apply the Image.fromarray method as well as the transformations on a list of images and should yield an error.
You could extend this class as a custom CIFAR10 dataset and apply these methods in a loop for each loaded sample.