Hi, @CS.Enthu. You could also use the grid sampler and aggregator in TorchIO 39 if you don’t want to worry about low-level issues:
import torch
from torch.utils.data import DataLoader
import torchio as tio

t = torch.rand(1, 284, 143, 143)
subject = tio.Subject(image=tio.ScalarImage(tensor=t))
sampler = tio.data.GridSampler(subject, (1, 128, 128))
len(sampler)  # 1136
loader = DataLoader(sampler, batch_size=64)
len(loader)  # 18
aggregator = tio.data.GridAggregator(sampler)
for batch in loader:
    aggregator.add_batch(batch['image']['data'], batch['location'])
output = aggregator.get_output_tensor()
output.shape  # torch.Size([1, 284, 143, 143])