@ptrblck  Okay I think above code is too simplified.
overall, from my whole dataset,  _getMegabatch will get Mega-batch dataset[start:end]
then from the megabatch I want to return minibatches.
Specifically, my whole dataset is a list [images, texts], images.shape = [20000, 224, 224, 3], texts.shape=[20000, 30]
and _getMegabatch() slices whole data to mega-batch data [images, texts] with images.shape = [6, 224, 224, 3] texts.shape=[6,30]  mega-batch size 6 is just an example.
For easy understanding let’s represent this mega-batch data  images (shape [6, 224, 224, 3] and texts as [a, b, c, d, e, f], [1,2,3,4,5, 6], each alphabet, number is image and text.
From this mega-batch data I am gonna get all 4-length sub-sequence datas with _getsubsequence like self.data =[ [ [a, b, c, d], [b, c, d, e], [c, d, e, f] ], [ [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6] ] ]
Finally, __getitem__ will return self.data[0][index], self.data[1][index] e.g. [a, b, c, d], [1, 2, 3, 4]
I`m not sure this mega-batch \in mini-batch dataloader structure is efficient or not.