For reference, you can take a look at Datasets & Dataloaders — PyTorch Tutorials 1.8.1+cu102 documentation 1 or other repos like vision/torchvision/datasets at master · pytorch/vision · GitHub
Also, can you post a code snippet to better understand the problem?