You could try to batch samples according to their length or you could also pad them. @vdw shares some great resources here from the NLP domain, which deals with similar challenges.