You can just use numpy:
self.rand_idx = np.arange(len(self.Test))
np.random.shuffle(self.rand_idx)

The second error is because the self.cifar_len = 10, your index should be less then 10.
I don’t know why you limited your shuffled version to only contain the first 10 data, but if you need to do so, the len of dataset should then be 10, since now it’s 10000 it tries to request something like self.rand_idx[50] which doesn’t exists and gives you the error.