Length should be the number of targets you want your model to predict.
For the relation: I’d probably look at your application for this. Clearly you want your model to be able to predict your targets, so you have this target length plus number of elements equal to their predecessor formula as a lower bound. Very long inputs for a given target length lead to a very imbalanced stepwise prediction problem because the effectively the model needs to assign a lot of probability to the blanks to get to sane losses. Probably look at established models in your domain and go with the flow until you have reason to believe that  you can improve it.
Best regards
Thomas