[Whisper] Freeze params of encoder
Author: sanchit-gandhi
Pull request: yes

# What does this PR do?

Adds a method to Whisper to freeze the parameters of the encoder and two associated tests. 

API:
```python
whisper_model.freeze_encoder()
```
This is in-line with Wav2Vec2 where we freeze the feature encoder with the method [`.freeze_feature_encoder()`](https://github.com/huggingface/transformers/blob/bbd150e92f84db72e7507d0c3ce69474b2948839/src/transformers/models/wav2vec2/modeling_wav2vec2.py#L1220):
```python
wav2vec2_model.freeze_feature_encoder()
```

## Sanity check
```python
from transformers import WhisperConfig, WhisperForConditionalGeneration

config = WhisperConfig()
model = WhisperForConditionalGeneration(config)

# check if params are frozen
encoder_grads = [param.requires_grad for param in model.model.encoder.parameters()]
decoder_grads = [param.requires_grad for param in model.model.decoder.parameters()]

print("Before freezing encoder...")
print(f"All encoder params trainable: {all(encoder_grads)}")
print(f"All decoder params trainable: {all(decoder_grads)}")
 
# freeze params of encoder
model.freeze_encoder()

# check if params are frozen
encoder_grads = [param.requires_grad for param in model.model.encoder.parameters()]
decoder_grads = [param.requires_grad for param in model.model.decoder.parameters()]

print("After freezing encoder...")
print(f"All encoder params trainable: {all(encoder_grads)}")
print(f"All decoder params trainable: {all(decoder_grads)}")
```
```
Before freezing encoder...
All encoder params trainable: True
All decoder params trainable: True
After freezing encoder...
All encoder params trainable: False
All decoder params trainable: True
```

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/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/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

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

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._