Growing allocated memory issue for every batch during training

A simple Dataset example using a sliding window can be found here but note that the sequence length would be static and would not increase (up to 4) as in your example image B.