I want to change the order of shuffle and batch. Normally, when using the dataloader, the data is shuffles and then we batch the shuffled data:
import torch, torch.nn as nn
from torch.utils.data import DataLoader

x = DataLoader(torch.arange(10), batch_size=2, shuffle=True)


print(list(x))

batch [tensor(7), tensor(9)]
batch [tensor(4), tensor(2)]
batch [tensor(5), tensor(3)]
batch [tensor(0), tensor(8)]
batch [tensor(6), tensor(1)]


what I want is first batch then shuffle. One example output is as following:
batch [tensor(6), tensor(7)]
batch [tensor(0), tensor(1)]
batch [tensor(2), tensor(3)]
batch [tensor(8), tensor(9)]
batch [tensor(4), tensor(5)]