I could imagine then I need a for loop inside  __getitem__ method for going into all the folders that contain the images. Or I need two index values 1. for going into a folder 2. for getting an image.
I thought of another approach that is to run a script that creates a .txt file that contains full paths to all the images with its labels.
After this, I just need an index value to get an image at a location that is at line number:index of the .txt file.