Hi Here is my train loader:
from torch.utils.data import DataLoader, TensorDataset, Dataset
train_dataset = DatasetTrain(train)
    valid_dataset = DatasetTrain(valid)
    print(train_dataset.max_len, valid_dataset.max_len)
    train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset) if args.distributed else None
    valid_sampler = torch.utils.data.distributed.DistributedSampler(valid_dataset) if args.distributed else None
    train_loader = DataLoader(train_dataset, sampler=train_sampler, batch_size=args.train_batch_size,
                              shuffle=(not args.distributed), collate_fn=collate_fn)
    valid_loader = DataLoader(valid_dataset, sampler=valid_sampler, batch_size=args.valid_batch_size, shuffle=False,
                              collate_fn=collate_fn)

The variables train and valid are just lists of the length previously I mentioned in the question.