Fix TF generation (especially for `TFMarian`)
# What does this PR do?

Fix TF generation (especially for the `TFMarian` generation issue in #18149)

Fix #18149
_The documentation is not available anymore as the PR was closed or merged._<|||||>Hey @ydshieh 👋 

Thank you for opening this PR, it made me realize a detail that is wrong in *both* frameworks 👀 

We know that logprobs is a negative value, and we want to maximize it in beam search (i.e. make it as close to 0 as possible). Since logprobs is always negative, and the final score is the sum of the logprobs, we can anticipate the best possible score and use it to end beam search with no drawback. Well, it turns out that the method to compute the best possible score depends on `length_penalty`, and we are not accounting for that!

- Scenario 1, length_penalty > 0.0: In this case, as the sentence grows, the denominator grows as well. This means the score can get closer to 0 (i.e. higher) as the sentence grows, and longer sentences are promoted. In this case, the best possible score can be determined from the maximum sequence length (TF implementation).
- Scenario 2, length_penalty < 0.0: In this case, as the sentence grows, the denominator gets smaller. This means the score will get farther away to 0 (i.e. lower) as the sentence grows, and shorter sentences are promoted. In this case, the best possible score can be determined from the current sequence length (PT implementation).

On top of this incomplete best score computation on both ends, your PR made me realize that the stopping condition for TF also had a problem (after factoring in the correct length penalty computation, a few tests failed).

I'm opening a PR to compare against this one with what I think is the correct solution to this bug 🐛 

<|||||>Close in favor of #20901