Fix Loading of Flax(Speech)EncoderDecoderModel kwargs from PreTrained Encoder-Decoder Checkpoints
Author: sanchit-gandhi
Pull request: yes

This PR modifies the `from_encoder_decoder_pretrained` class methods in the Flax(Speech)EncoderDecoderModels to correctly instantiate an encoder and a decoder from specified pre-trained model names or paths **given** a set of keyword arguments (kwargs). We should be able to pass encoder/decoder specific kwargs into the `from_encoder_decoder_pretrained` method to override the config of the pre-trained checkpoints. The following code snippet provides a short PyTorch script to demonstrate this desired behaviour using the encoder kwarg `add_adapter`:
```python
from transformers import SpeechEncoderDecoderModel
encoder_id = "hf-internal-testing/tiny-random-wav2vec2"
decoder_id = "hf-internal-testing/tiny-random-bart"
model = SpeechEncoderDecoderModel.from_encoder_decoder_pretrained(encoder_id, decoder_id, encoder_add_adapter=True)
print(model.config.encoder.add_adapter)
model = SpeechEncoderDecoderModel.from_encoder_decoder_pretrained(encoder_id, decoder_id, encoder_add_adapter=False)
print(model.config.encoder.add_adapter)
```
Output:
```python
True
False
```
Reproducing the same script using the equivalent Flax model yields an error, the model not being able to be correctly instantiated:
```python
from transformers import FlaxSpeechEncoderDecoderModel
encoder_id = "hf-internal-testing/tiny-random-wav2vec2"
decoder_id = "hf-internal-testing/tiny-random-bart"
model = FlaxSpeechEncoderDecoderModel.from_encoder_decoder_pretrained(encoder_id, decoder_id, encoder_add_adapter=True, encoder_from_pt=True, decoder_from_pt=True)
```
Output:
```python
File ~/transformers/src/transformers/models/wav2vec2/modeling_flax_wav2vec2.py:857, in FlaxWav2Vec2PreTrainedModel.__init__(self, config, input_shape, seed, dtype, **kwargs)
    849 def __init__(
    850     self,
    851     config: Wav2Vec2Config,
   (...)
    855     **kwargs,
    856 ):
--> 857     module = self.module_class(config=config, dtype=dtype, **kwargs)
    858     super().__init__(config, module, input_shape=input_shape, seed=seed, dtype=dtype)

TypeError: __init__() got an unexpected keyword argument 'add_adapter'
```
The encoder and decoder kwargs are incorrectly passed to the `__init__` method of the respective module. This raises a TypeError when loading from pre-trained checkpoints, the kwargs being unexpected arguments.

This PR amends the loading of the encoder and decoder models to handle such kwargs correctly. It's implementation is verified through a new rigorous test: `test_encoder_decoder_model_from_encoder_decoder_pretrained`. An encoder-decoder model is loaded with two kwargs set opposite to that specified in the standalone encoder and decoder configs. It asserts that the corresponding attributes in the _new_ encoder-decoder model config are in-fact set opposite to those in the standalone encoder and decoder configs.

Following these changes, the Flax script yields the desired output:
```python
from transformers import FlaxSpeechEncoderDecoderModel
encoder_id = "hf-internal-testing/tiny-random-wav2vec2"
decoder_id = "hf-internal-testing/tiny-random-bart"
model = FlaxSpeechEncoderDecoderModel.from_encoder_decoder_pretrained(encoder_id, decoder_id, encoder_add_adapter=True, encoder_from_pt=True, decoder_from_pt=True)
print(model.config.encoder.add_adapter)
model = FlaxSpeechEncoderDecoderModel.from_encoder_decoder_pretrained(encoder_id, decoder_id, encoder_add_adapter=False, encoder_from_pt=True, decoder_from_pt=True)
print(model.config.encoder.add_adapter)
```
Output:
```python
True
False
```

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