You could organizes your sequences in such a way that all sequences in a batch have the same length using a sampler.