I think we can achieve it by doing the following, @grid_world @ptrblck
class your_new_custom_dataset_class(torchvision.datasets.CIFAR10):  #<----Important
    def __init__(self):
        super(your_new_custom_dataset_class, self).__init__()
        self.get_filenames()    #<----Important
    
    def __getitem__(self, index):
        img, label = self.data[index], self.labels[index]
        filename = self.filenames[index]       #<----Important

        img = Image.fromarray(img)

        if self.transform is not None:
            img = self.transform(img)

        if self.target_transform is not None:
            label = self.target_transform(label)

        return img, label, filename      #<----Important
    
    def get_filenames(self):    #<----Important
        self.filenames = []
        if self.train:
            downloaded_list = self.train_list
        else:
            downloaded_list = self.test_list
            
        for file_name, checksum in downloaded_list:
            file_path = os.path.join(self.root, self.base_folder, file_name)
            with open(file_path, 'rb') as f:
                self.entry = pickle.load(f, encoding='latin1')
            self.filenames.extend(self.entry["filenames"]) 

PS. The implementation is a bit sloppy, just make sure to note all the lines with the #<----Important comment.