In your code snippet you are not using the index, but load the complete pickle file and split it into the features and target tensors. I assume you could load the file in the __init__ and index it in the __getitem__ using the passed index value.