Initially, I thought about that, but with the split of sklearn i can divide the initial dataset in just two part, or at least 2 split at the time from what I understood. I tried to apply this method using the split given by torch and have multiple split, but like before I have as a result subsets and so I could not access to the targets and data of that subset.
Thanks for the help, but for now I will continue using this custom class, that seems work fine
    def __init__(self, subset, label):
        self.subset = subset
        self.targets = []
        self.data = []

        indeces = subset.indices
        for index in indeces:
            if subset.dataset.__getitem__(int(index))[1] == label:
                continue
            else:
                self.data.append(subset.dataset.__getitem__(int(index))[0])
                self.targets.append(subset.dataset.__getitem__(int(index))[1])

    def __len__(self):
        return len(self.data)

    def __getitem__(self, idx):
        img, target = self.data[idx], int(self.targets[idx])
        return img, target
type or paste code here