I can’t find the exact code, I’ll just show a sample.
def collate_fn(batch: List[Tuple[Tensor, int]]):
    inps, labels = zip(*data)
    return list(map(lambda x: x.pin_memory(), inps), tc.tensor(labels).pin_memory()
def train(...):
    for inp, labels in LOADER:
        for i in inp:
            i = i.to(device=DEVICE, non_blocking = True)
        labels = labels.to(device=DEVICE, non_blocking = True)
        OPTIM.zero_grad()
        ...

My code should be something like this, and I pad the tensors inside the model.