You could try to adapt this example

Excellent! Thank you! I will keep you updated.

but I think the proper approach would be to create or read the indices either in the sampler  or the Dataset  without the need to manipulate it.

For clarity, an index is simply the ID of an image which I use in conjunction with __getitem__ to get the right image. The issue comes with V{1, 2} as described in my initial pseudocode. If by indexes you are referring to this V, then what you suggest cannot be generated in the Dataset (or sampler) as they are predictions made by a neural network.

If you are using two indices, one for the data sample and another one for the coordinates, would it be possible to create a list of indices  of these pairs and increase the length of the dataset to sample from them?

I am not sure I am following 100% but I will stick to my previous answers and provide more background information. The input images are huge (lookup histopathology images), and as such, they cannot be pre-processed to accommodate for all the possible values of V{1, 2}. Ideally, this should be done dynamically, i.e. only access the part of an image that the model desires to observe. Since I’d like the model to have multiple ‘chances’ of looking at an image, I need to access an image multiple times but each time looking at a specific part of it as defined by V.
In a simpler world, I would be able to store this image in memory, and use indexes to directly extract these glimpses, but unfortunately this is not possible with my data set (typical compressed size of each image is 3-8 GB). Hence, I use openslide (https://openslide.org/api/python/) to access my images, each time passing coordinates and magnification level (which is what I’ve defined as V above) to extract a specific patch of the image dynamically.