Even in __getitem__ it is still fine for me as long as I use num_workers=0 in DataLoader.
But when I use num_workers=1, then it gets reset to zero as you have mentioned. Do you have to use num_workers > 0?