U should write a custom collate_fn and sort the data inside it, below is an example:
def collate_fn(batch):
    inp, labels = zip(*batch)
    inp = SORTED_VERSION
    return pad_sequence(inp), tc.stack(labels)

(I assume each index from ur dataset returns a tuple with 2 tensors)