Extend ImageFolder in pytorch to return a tensor of a different shape?

How to extend torch.datasets.ImageFolder in pytorch to return a tensor of a different shape?

It currently returns: torch.Size([1, 3, 256, 256]). I want to return [1, 10, 3, 256, 256].

I have a directory with multiple images separated into folders. Each folder has up to 3000 images. I would like to modify the getitem function so that it returns bags of images, where each bag contains 10 images.

Thank you!

Is this a double post from here or are these use cases somehow different?