I’m slowly wrapping my head around proper use of a custom DataSet as used by the DataLoader.
I have a torch.utils.data.Dataset which utilizes a:
def __getitem__(self, idx):
    ...
    return { "image": X_ims, "label": Y}

when I supply the DataLoader with a batch_size I get the expected number of samples back.  But the documentation is a bit unclear with regard to what the workers are doing.  The documentation mentions that they are getting samples from the DataSet, and I am “assuming” that the prefetch_factor is the number of samples they are retrieving.  Do they do this until another entire batch is loaded ( ideally while my model is training)?  or is each worker trying to collect a full batch of samples?
The question arises because I find I am often stuck waiting on DataLoader’s
_next_data() > _get_data() > _try_get_data() > _get() > _wait() method.  Which I take to mean that it is waiting for the workers to get back with all the samples.
If I have a large batch size ( 1000 ), assuming I have num_workers=2 should I set the prefetch_factor=500?  In the hope each worker is able to get enough samples for the next batch by the time I’m ready for it?