It depends how you are loading each sample.
The __len__ method returns the length of the complete Dataset and thus also defines the used indices (passed into __getitem__).
E.g. if you are loading single images via the passed index in __getitem__, the length should define the total number of images in your dataset.