PTA:

seems you are doing the sort/unsort stuff for sequence packing out of the forward method, which you should do inside based on your input


do you mean that i should sort the sequence in the forward method rather than in the train_one_epoch method?