you can set batch_size = 1 in Dataloader, and write your dataset. You may refer to

  
      github.com
  
  
    pytorch/vision/blob/master/torchvision/datasets/folder.py#L123-128 24

def __getitem__(self, index):
    """
    Args:
        index (int): Index


    Returns:
        tuple: (image, target) where target is class_index of the target class.
    """
    path, target = self.imgs[index]
    img = self.loader(path)
    if self.transform is not None:
        img = self.transform(img)
    if self.target_transform is not None:
        target = self.target_transform(target)


    return img, target


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



  
  
    
    
  
  


It’s something like:
   def __getitem__(self, index):

        path, target = self.imgs[index]
        img = self.loader(path)
        # ......
        for ii in range(batch_size):
             img_ = random_crop(img)
             imgs.append(img_)
        return torch.stack(imgs), target