I’m not sure what exactly is causing the issue and cannot easily debug it as I don’t have the files.
However, here is a small example of what I had in mind:
class MyDataset(Dataset):
    def __init__(self):
        self.data = torch.randn(10, 3, 24, 24)
    
    def __getitem__(self, index):
        # get current sample
        x = self.data[index]
        # create patches
        x = x.unfold(1, 12, 12).unfold(2, 12, 12)
        #flatten patches
        x = x.contiguous().view(x.size(0), -1, x.size(3), x.size(4))
        x = x.permute(1, 0, 2, 3)
        return x
        
    def __len__(self):
        return len(self.data)

dataset = MyDataset()
loader = DataLoader(dataset, batch_size=2)
x = next(iter(loader))
print(x.shape)
> torch.Size([2, 4, 3, 12, 12])

Inside the Dataset.__getitem__ you are creating 4 patches of the shape 12x12 and returning these 4 patches in a shape of [patches=4, channels=3, height=12, width=12].
The DataLoader uses the batch_size to specify how often the __getitem__ is called and stacks the returned tensors in a newly created dim0.
For a batch size of 2, the returned batch will have thus the shape [batch_size=2, patches=4, 3, 12, 12] and you could flatten the patches into the batch dimension in order to feed it into the model.