Judging from the source code of RandomSampler, data_source is only there to provide the number of elements . If u need to sample from some specific indexes, I guess writing your own Sampler would work, it’s not very hard.