Solved by HenryPowell in post #5 
              
              
                Thanks a lot for your suggestion. I actually managed to solve the issue by creating a list of tuples of (data_file_path, desired_index, class_label) and then just returned tuple((torch.load(data_file)[desired_index: desired_index + window_size], label)) and used this to generate batches. 
For anyone…