If you have a look at the RandomSapler class and you understand it, it is almost done.
class RandomSampler(Sampler):
    """Samples elements randomly, without replacement.

   Arguments:
        data_source (Dataset): dataset to sample from
    """

   def __init__(self, data_source):
       self.data_source = data_source

   def __iter__(self):
       return iter(torch.randperm(len(self.data_source)).long())

   def __len__(self):
       return len(self.data_source)

How does it work ? It is sampling your dataset according to the permutation order (iter function). So how would you modify it to suit your needs ?
Ps : Read your post before posting please… Some typos in your previous post.