Thanks for your answer, but using only dataloader parameters won’t fix items within batch,
I rather came up with an idea, which is

receive the ‘random’ minibatch index from a dataloader with parameter batch_size=1

getitem function in my custom Dataset class delivers consecutive items of mini-batch size (suppose k) once called.

def __getitem__(self, index):
    batch_item = torch.zeros(self.batch_size, self.data_size)
    for i in range(index*self.batch_size, (index+1)*self.batch_size):
        batch_item[i] = self._get_data_function(i) # custom single data getter function for given index
    return batch_item

However, I’m worried about the ‘for loop’ which might harm speed.