Hi, thanks you for asking and sharing the answer this!
I encountered the same issue and tried to use your code. But I wonder if it is possible get all data with [train_dataset.indices]. I’m not sure whether it’s a list or array or a single index. If [train_dataset.indices] is a single index, two for loop are needed at the end. Is this what you do exactly?