docs: def sampler_to_iterator(dataset, sampler):
      """ Given a batch sampler or sampler returns examples instead of indices
  
      Args:
          dataset (torch.utils.data.Dataset): Dataset to sample from.
          sampler (torch.utils.data.sampler.Sampler): Sampler over the dataset.
  
      Returns:
          generator over dataset examples
      """
      for sample in sampler:
          if isinstance(sample, (list, tuple)):
              # yield a batch
              yield [dataset[i] for i in sample]
          else:
              # yield a single example
              yield dataset[sample]