RNN loss with packed/padded input

Maybe this older post might be interesting. The idea is to create a Sampler to ensure that all samples withing a batch have the same combination of input and target lengths.