Add script to convert HF Whisper models back to OpenAI format
Author: zuazo
Pull request: yes

# What does this PR do?

This PR introduces a new script named `convert_hf_to_openai.py` that allows for the conversion of Hugging Face Whisper models back to the original OpenAI Whisper format. This just does the opposite of the [`convert_openai_to_hf.py`](https://github.com/huggingface/transformers/blob/main/src/transformers/models/whisper/convert_openai_to_hf.py) script.

While Hugging Face is easier to use, for example, [for fine-tuning](https://huggingface.co/blog/fine-tune-whisper) and has many integrations, the original OpenAI Whisper library provides more fine-grained control over this specific model, facilitating the testing of new approaches and certain algorithms (at least in our case).

## Doctests

I added a doctest at the beginning that passes, but it requires the `openai-whisper` package to be installed, so I left it disabled with the double `>>`. Not sure how do you prefer to handle this case: leave it like that, adding the Whisper package somewhere in the CI (like [`.github/workflows/doctests.yml`](https://github.com/huggingface/transformers/blob/main/.github/workflows/doctests.yml)), or in any other way.

Besides, even though the original `convert_openai_to_hf.py` script did not have them, let me know if you want me to add some tests to this. I have tested it myself to work with all the Whisper model sizes, even the Large V2.

## Before submitting

- [ ] This PR fixes a typo or improves the docs.
- [x] 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.
- [x] 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?

Possible candidates:
- `convert_openai_to_hf.py` script creator: @ArthurZucker
- Speech models: @sanchit-gandhi


Comments:
Linking #20953 as it was asked quite a while ago. We don't usually add these in transformers and would rather add it to the `## resource` section, as a link to a your repo with the script. WDYT @sanchit-gandhi 

Probably in the Resource section would be best here @zuazo! It becomes a bit difficult to maintain Transformers if we become a one-to-many export library (e.g. export Transformers format to any number of other libraries).

Curious to hear what parameters you need from the OpenAI implementation that we don't offer in Transformers though! We can certainly discuss on GitHub adding them to Transformers to improve the experience for you. Currently, we're a lot faster than OpenAI: https://twitter.com/reach_vb/status/1714741554030481786

Absolutely, it sounds reasonable. I will open a new PR to add it to the `## Resources` section once we finish PR #26834 to avoid any merge conflicts.

Regarding our usage, we have experimented with [HF fine-tuned Whisper models](https://huggingface.co/blog/fine-tune-whisper) coupled with n-gram LMs. It seemed straightforward in the whisper library due to their existing [`BeamSearchDecoder`](https://github.com/openai/whisper/blob/b38a1f20f4b23f3f3099af2c3e0ca95627276ddf/whisper/decoding.py#L299), making it simple to incorporate a KenLM.

If there is a similar feature in Transformers that I overlooked, I apologize. Navigating through such a comprehensive library can sometimes be challenging.

Interesting use-case! Did you find that the Whisper decoder was not enough to predict accurate spelling/transcriptions? The Whisper decoder is in effect an "internal" LM, since it plays the role of generating the text conditional on the encoder hidden-states. Is your n-gram LM trained with the same vocab size as Whisper, i.e. you use the Whisper logits in combination with the n-gram model to get your final transcription? We have something similar to this with Wav2Vec2 + n-gram here: https://github.com/huggingface/transformers/blob/34a640642be61e0e2eb622e497140be3aea202bc/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py#L284