Remove max length beam scorer
# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #11040
Modifies ad per the comments from Pull #11122 


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [X] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [X] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?
@patil-suraj ; @patrickvonplaten ; @Narsil 


Note: I have modified code in the `./tests/` where, `max_length` was used with `beam_scorer`.
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

Awesome job @GeetDsa - this looks good to me :-) 

Also pinging @patil-suraj and @Narsil for review.<|||||>@Narsil - do you think we need a test here or should this be fine without?<|||||>Hi @patrickvonplaten , Most of the errors are caused because of "max_length" attribute used while creating `beam_scorer` object in the test cases. These errors are arising as the beam_scorer attribute is removed from the source code. Infact, I had modified the files under `tests/*` to take account for this.(This can be found in my commits. Sorry that I did not had different commits for the actual source code and the tests).  So, may be can you review the files that I have modified under `tests/*`  as well?<|||||>I think we shouldn´t modify the tests if possible (thats what make backward compatiblity enforced).

Instead, we should probably : 
- add some warning for users that used the raw components/functions
- point the towards a better solution
- modify the tests that DO raise warnings to make sure we do raise them (and also swallow them in the logs) (they become backward compatibility tests their names should probably reflect that too) (We can remove some backward tests if they are very redundant btw)
- Have new tests that point show new API.
- Higher level tests (within models) should not be affected.
@GeetDsa  I can do this for you if you want.<|||||>> I think we shouldn´t modify the tests if possible (thats what make backward compatiblity enforced).
> 
> Instead, we should probably :
> 
> * add some warning for users that used the raw components/functions
> * point the towards a better solution
> * modify the tests that DO raise warnings to make sure we do raise them (and also swallow them in the logs) (they become backward compatibility tests their names should probably reflect that too) (We can remove some backward tests if they are very redundant btw)
> * Have new tests that point show new API.
> * Higher level tests (within models) should not be affected.
>   @GeetDsa  I can do this for you if you want.

Hi @Narsil, I think it would be better if you can do it, as I don't really know how to deal with tests.<|||||>> > I think we shouldn´t modify the tests if possible (thats what make backward compatiblity enforced).
> > Instead, we should probably :
> > 
> > * add some warning for users that used the raw components/functions
> > * point the towards a better solution
> > * modify the tests that DO raise warnings to make sure we do raise them (and also swallow them in the logs) (they become backward compatibility tests their names should probably reflect that too) (We can remove some backward tests if they are very redundant btw)
> > * Have new tests that point show new API.
> > * Higher level tests (within models) should not be affected.
> >   @GeetDsa  I can do this for you if you want.


 Hi @Narsil, I think it would be better if you can do it, as I don't really know how to deal with tests.

<|||||>I'll take care of it<|||||>@Narsil - I think we don't need to add a test here. By design the PR prevents errors such as the one mentioned in the issue - It's not possible anymore to pass `max_length` to `BeamSearchScorer` and thus a test doesn't make much sense here IMO.<|||||>Will wait for https://github.com/huggingface/transformers/pull/11442 to be merged before rebasing this one to merge<|||||>@patrickvonplaten But if users were using the BeamScorer object, that's a breaking change, isn't it ?<|||||>> @patrickvonplaten But if users were using the BeamScorer object, that's a breaking change, isn't it ?

Yes true. IMO, no functionality is lost though because:

- Previously, if one had passed `max_length` to both `def beam_search(...)` and `BeamSearchScorer(...)`, then there would have been a bug (see issue). The correct way of fixing the bug (while still allowing `BeamSearchScorer(...)` to accept `max_length`) would have been to overwrite `BeamSearchScorer's` max_length with `beam_search(...)`'s max_length. On the other hand it's never possible to **not** pass `max_length` to `def beam_search(...)` => therefore I think either way the `max_length` arg to `BeamSearchScorer` is useless (the `max_length` value of `beam_search(...)` would have been preferred in any way. 

=> However, we could/should probably add `**kwargs` to `BeamSearchScorer` that throws a warning if `max_length` is passed & says that's it's deprecated. This would be cleaner overall and have no breaking changes - what do you think @Narsil ?<|||||>Yep, that's what I had in mind, just accept it, raise a warning (and ignore it, exactly as it used to if I understand correctly) <|||||>> Yep, that's what I had in mind, just accept it, raise a warning (and ignore it, exactly as it used to if I understand correctly)

Done! Could you review one last time and merge if ok for you? @Narsil <|||||>@patrickvonplaten, thank you for taking care of it. I found a small issue in the warning message. The message provided in the latest commit is ""`max_length` should be passed directly to `beam_search(...)`, `beam_sample(...)`"", shouldn't you include "generate(..)" as well, as sometime, `generate(...)` inherently calls `beam_search(..,)` or `group_beam_search(..,)`, or other relevant functions.<|||||>> @patrickvonplaten, thank you for taking care of it. I found a small issue in the warning message. The message provided in the latest commit is ""`max_length` should be passed directly to `beam_search(...)`, `beam_sample(...)`"", shouldn't you include "generate(..)" as well, as sometime, `generate(...)` inherently calls `beam_search(..,)` or `group_beam_search(..,)`, or other relevant functions.

Hey @GeetDsa, 

It should be fine, since the warning is impossible to be triggered by `generate(...)` since when one calls `generate(...)`, one cannot pass `max_length` to `BeamScorer` 