However, when the sequence is very sparse, i.e the maximum length is very large, while each sequence might very small. In this case, padding will waste a lot of memory.
Is there any other way to resolve this?