GenerationConfig bug on Transformers >4.26.0 by using Whisper and model.generate()
Author: javilonso
Pull request: no

### System Info

- `transformers` version: 4.26.1
- Platform: Linux-3.10.0
- Python version: 3.9.13
- Huggingface_hub version: 0.11.0
- PyTorch version (GPU?): 1.11.0+cu102 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No




### Who can help?

@gante

### 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

I have fine tuned a Whisper model and by using `model.generate(...)` to do the inference with the new version transformers library 4.26.0 I got an error (not happening in 4.25.0).

My error is related with **GenerationConfig**, something that was changed from 4.26.0.

```
pred_ids = model.generate(
            encoder_outputs=model.get_encoder()(data_batch['input_features'].to(device), attention_mask=None),
            attention_mask=None,
            )
```

### **Error trace:**

`(\n  File \"/mydir/lib/python3.9/site-packages/torch/autograd/grad_mode.py\", line 27, in decorate_context\n    return func(*args, **kwargs)\n  File \"/mydir/lib/python3.9/site-packages/transformers/generation/utils.py\", line 1183, in generate\n    if self.generation_config._from_model_config:\n  File \"/mydir/lib/python3.9/site-packages/torch/nn/modules/module.py\", line 1185, in __getattr__\n    raise AttributeError(\"'{}' object has no attribute '{}'\".format(\nAttributeError: 'WhisperForConditionalGeneration' object has no attribute 'generation_config'\n"`

### **Error location:**
Line 1174-1187
https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py



### **Possible solution:**

By adding following line before `model.generate(...)` I don't have any error
`model.generation_config = GenerationConfig.from_model_config(model.config)`

Comments:
cc'ing our generation expert @gante 

Hi @javilonso 👋  There is a high likelihood that you are seeing an error due to an unfortunate combination of events, and I'd like to pin that down (e.g. a model trained in v4.25 + loading without `from_pretrained`).

Can you share a reproducible script? 🙏 

Thanks @gante for checking the issue!

You are right, I am not using `from_pretained` to load the model. 
Instead, I'm using MLFlow hub, so the way to load models is `mlflow.pytorch.load_model(....)`.

By having a look at MLFlow source code, they upload the model via **torch**, so they don't use HuggingFace `from_pretained`.

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.

Even though I am using "WhisperForConditionalGeneration.from_pretrained", I met the same bug