Add warnings for incompatible generation parameters
Author: jsrozner
Pull request: yes
Labels: name: wontfix

# What does this PR do?
While testing various generation configurations, I got confused when beam_sample's outputs (i.e. `num_beams > 1, do_sample=True`) failed to change with different settings of `top_k, top_p, temperature`. Then I realized that in my call to `generate()`, `do_sample` was still set to false even though I was cycling through various settings of top_k, top_p and temperature. 

Generate (and its helper methods) already contain some parameter compatibility checks. This adds a few more checks:
- `num_beams` must be >= 1
- when `do_sample` is not set, warn the user if any of `top_p, top_k, temperature` are not None (since they will have no effect)
- if `num_beams` is 1 (no beam search), warn user if any of `early_stopping, length_penalty` are not None (since they will have no effect)
- if an invalid set of params `num_beams` and `do_sample` are passed, raise ValueError. Note that since we also add a check for `num_beams < 1`, this final value error will never be raised, but this prevents the `generate` function from falling off the end of the ifelse chain if something is altered in the future.


## 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?
- [ ] 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).
No doc changes necessary
- [ ] Did you write any new necessary tests?
ran tests, but no new functionality created, just warning messages


## Who can review?
 Please tag fewer than 3 people.
 Text Generation: @patrickvonplaten 

Comments:
Question: the `generate()` documentation says that `topk` etc params will default to values in the `pretrainedconfig`, but `top_k`, for example is never read from the config file. This differs from, e.g., `num_beams, max_length` which are read from config if they are not passed in as params to the generate function.

And since, for example, `T5PreTrainedModel` never overwrites the generate function, I don't see how the defaults in the config (for params like `top_k`) could actually end up being passed to the generate function?

> Question: the `generate()` documentation says that `topk` etc params will default to values in the `pretrainedconfig`, but `top_k`, for example is never read from the config file. This differs from, e.g., `num_beams, max_length` which are read from config if they are not passed in as params to the generate function.
> 
> And since, for example, `T5PreTrainedModel` never overwrites the generate function, I don't see how the defaults in the config (for params like `top_k`) could actually end up being passed to the generate function?

Regarding reading from config - am I missing something or do these never get checked? 

@patrickvonplaten 

> > Question: the `generate()` documentation says that `topk` etc params will default to values in the `pretrainedconfig`, but `top_k`, for example is never read from the config file. This differs from, e.g., `num_beams, max_length` which are read from config if they are not passed in as params to the generate function.
> > And since, for example, `T5PreTrainedModel` never overwrites the generate function, I don't see how the defaults in the config (for params like `top_k`) could actually end up being passed to the generate function?
> 
> Regarding reading from config - am I missing something or do these never get checked?
> 
> @patrickvonplaten

https://github.com/huggingface/transformers/blob/693ac3594b96e86dd282fdf8e413f3a48b176892/src/transformers/generation_utils.py#L240

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.