Using ImageFolder to load pairs of images with the same label

Hi,
I have a dataset of images with categorical labels and I’d like to sample it such that each sample is a pair of random images with the same label. Is there an easy way to do this? I’ve looked at the docs for ImageFolder, and Dataset but I saw no obvious way.