Generate: fix TF XLA tests on models with `max_position_embeddings` or `max_target_positions`
# What does this PR do?

Extracted from #20901 -- the lines added in this PR were incorrectly removed [here](https://github.com/huggingface/transformers/commit/0f78529f982eceb79c5855d0466c287ec8a18df1), causing some XLA tests to fail.

These changes fixes 8 slow TF tests on `test_xla_generate_slow`. They were also approved in the PR linked above, which was redone as part of the discussion (and closed).
_The documentation is not available anymore as the PR was closed or merged._