This error is expected now, since you’ve reduced the __len__ of the dataset, and this slicing will thus fail:
data = torch.zeros_like(self.X[i:])
data[:self.__len__()-i] = self.X[i:]

I’m currently unsure, why you are initializing data as a zero tensor in the shape of X[i:] and assign the values in the next line via a slicing operation.
Wouldn’t data = self.X[i:] just work?