Variable length of sequece for batching

i was making transformer of my own , but soon realized a problem that how to make batches osf sequences with variable length!!
can anyone plz help me figure out how it can be done?