Variable-sized batches from tf.data.Dataset?

Hi,

Supposing I have a tf.data.Dataset of rank-1 tensors of varying lengths, say up to 100. I would like to create a new dataset in which each element is a 1-d stack of a varying number of consecutive elements from the first dataset, totalling less than length 200.

I know I can do this using tf.data.Dataset.from_generator, but is there a better way?

Thanks in advance,

Henry