Custom batches in Data Loader

Hi,

I am currently building my own cnn model. While loading images in batches, i would like to load images that belong to a particular ID in one batch. the number of images that belong to an ID vary. All the images are in a folder and i have the mapping of IDs and images in a csv file. I failed to find an example online. Any help would be appreciated.