instead of sorting the sequences : using torch.nn.utils.rnn.pad_packed_sequences
you can try sorted(key, ‘reverse’) for sequence sorting without changing it actually.
and you can pass it directly into the input model and no need to reverse it accordingly