I think you could first preprocess your dataset, extract patches and perform padding by torchvision.transforms.functional.pad (link 5) and save the extracted and padded data to the disk. Then you could write a custom dataset and dataloader to load your processed data.