Override the function of collate_fn in DataLoader,
torch.utils.data.DataLoader(dataset=train_dataset, batch_size=setting.batch_size, num_workers=opt.nThreads, collate_fn=pack_x_new)

You should do something to update pack_x to pack_x_new which consumes the data from __get_item__() function.