How to use LogitsWarper within .generate()?
### System Info

- `transformers` version: 4.16.2
- Platform: Linux-5.4.0-100-generic-x86_64-with-glibc2.10
- Python version: 3.8.5
- PyTorch version (GPU?): 1.7.1+cu101 (True)

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

Using a GPT2 Model, I want to affect the logits, as they are used in the generate function. 

To do this, I created a LogitsWarper, which is the only member of the LogitsProcessorList:
```

logits_processor_list = LogitsProcessorList([
            TemperatureLogitsWarper(10.0)
                ])
```
This is then given as an argument to the generate() function:
```

beam_output = model.generate(
            sample,
            ...
            logits_processor_list=logits_processor_list,
            early_stopping=True,
            num_return_sequences=k,
            ...           
            do_sample=False,
            output_scores=True,
            return_dict_in_generate=True,
            length_penalty=0,

        )

```

### Expected behavior

When changing the temperature, I expect the output sequence probabilities to be different, but they do not differ between a temperature of 1.0 and 10.0.

My understanding is that logits_processor_list will be propagated to the specific search function that will be called (beam search, in this case). Should I do this differently, or is there an easier way to affect the temperature for all the search procedures? I know that .generate has a _temperature_ parameter, but this seems to only be used automatically when do_sample=True (https://github.com/huggingface/transformers/issues/22405) . How can I change the temperature when that is not the case?
Hi,

See this for a great blog post on that: https://towardsdatascience.com/the-power-of-constrained-language-models-cf63b65a035d.

The blog post includes a Colab notebook that showcases creating a custom `LogitsProcessor`<|||||>cc @gante <|||||>@JellePiepenbrock 👋 

Temperature only has an effect on sample-based text generation method. When no sampling is done (`do_sample=False`), the most likely token(s) will be selected at each token selection step, so temperature scaling doesn't change the output at all.

Have a look at this blog post: https://huggingface.co/blog/how-to-generate<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.