Are all images the same size? If the answer is yes, we can assume that each image is patched into P patches and there are N original images. Then  you can modify the dataset to be sth like this:
  class Dataset(object):
        #images are the full pre patchified images
        def __init__(self, images: List[str], P):
            self.images = images 
            self.transformer = Transform()
            self.num_patches = P
            
        
        def __getitem__(self, idx: int):
            img_idx = idx // self.num_patches
            patch_idx = idx % self.num_patches
            image = self.images[img_idx]
            #IMPORTANT switch to color later
            patches = patchify(image, (patch_size, patch_size, 3), step=patch_size)
    
            image_patches_tensor = self.transformer(patches[patch_idx])
            return image_patches tensor