Fix ViT hybrid model type in model config
Author: kshitij98
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #29862 


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] 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: _#29862_ 
- [ ] 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). -_Not applicable_
- [ ] Did you write any new necessary tests? -_Not required, trivial change_

## Testing

I am unable to run pytests as they keep crashing without any of the changes as well, I have attached the logs below. Probably something still missing in the developer workflow I've setup.

Otherwise, I have tested the code changes by instantiating the model, that works fine now.

```
>>> from transformers import VisionEncoderDecoderModel, BertConfig, BertGenerationDecoder, ViTHybridConfig, \
...     ViTHybridModel
>>> decoder = BertGenerationDecoder(BertConfig())
>>> encoder = ViTHybridModel(ViTHybridConfig())
>>> model = VisionEncoderDecoderModel(encoder=encoder, decoder=decoder)
>>>
>>> model
VisionEncoderDecoderModel(
  (encoder): ViTHybridModel(
    ...
  )
  (decoder): BertGenerationDecoder(
    ...
  )
)
```

## Environment details

- `transformers` version: 4.40.0.dev0
- Platform: Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.22.1
- Safetensors version: 0.4.2
- Accelerate version: 0.28.0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.2.1+cu121 (True)
- Tensorflow version (GPU?): 2.15.1 (True)
- Flax version (CPU?/GPU?/TPU?): 0.7.0 (cpu)
- Jax version: 0.4.13
- JaxLib version: 0.4.13
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

## Who can review?

@amyeroberts @jbdel

<!-- 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:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->

## Error logs

```console
(.env) ➜  transformers git:(vit-hybrid-model-type) python3 -m pytest -n auto --dist=loadfile -s -v ./tests/models/vit_hybrid
2024-03-27 20:32:53.338348: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-27 20:32:53.338491: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-27 20:32:53.350148: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-27 20:32:54.758693: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
=================================================================== test session starts ====================================================================
platform linux -- Python 3.10.12, pytest-7.4.4, pluggy-1.4.0 -- /home/kshitij/github/kshitij98/transformers/.env/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/kshitij/github/kshitij98/transformers/.hypothesis/examples'))
rootdir: /home/kshitij/github/kshitij98/transformers
configfile: pyproject.toml
plugins: hypothesis-6.99.13, xdist-3.5.0, picked-0.5.0, timeout-2.3.1, dash-2.16.1
initialized: 4/4 workers[1]    1408 killed     python3 -m pytest -n auto --dist=loadfile -s -v ./tests/models/vit_hybrid



(.env) ➜  transformers git:(vit-hybrid-model-type) python3 -m pytest -n 1 --dist=loadfile -s -v ./tests/models/vit_hybrid
2024-03-27 20:35:47.976887: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-27 20:35:47.977047: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-27 20:35:47.979643: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-27 20:35:49.492979: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
=================================================================== test session starts ====================================================================platform linux -- Python 3.10.12, pytest-7.4.4, pluggy-1.4.0 -- /home/kshitij/github/kshitij98/transformers/.env/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/kshitij/github/kshitij98/transformers/.hypothesis/examples'))
rootdir: /home/kshitij/github/kshitij98/transformers
configfile: pyproject.toml
plugins: hypothesis-6.99.13, xdist-3.5.0, picked-0.5.0, timeout-2.3.1, dash-2.16.1
initialized: 1/1 worker2024-03-27 20:35:55.466678: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-27 20:35:55.466743: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-27 20:35:55.467575: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-27 20:35:56.290601: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
1 worker [109 items]
scheduling tests via LoadFileScheduling

tests/models/vit_hybrid/test_modeling_vit_hybrid.py::ViTHybridModelTest::test_attention_outputs
[gw0] node down: Not properly terminated
[gw0] FAILED tests/models/vit_hybrid/test_modeling_vit_hybrid.py::ViTHybridModelTest::test_attention_outputs

replacing crashed worker gw0
```

Comments:
cc @amyeroberts 

Thanks for the review @amyeroberts, loading the pretrained model was failing, and is currently failing in prod as well with the error: 
![image](https://github.com/huggingface/transformers/assets/12982388/e1b78eb3-afd2-4f3a-a929-9cc714079574)


because the pretrained model has `vit-hybrid` instead of `vit_hybrid` in the config. So I've updated all instances to `vit-hybrid` instead.

---

For testing, I've checked both initialisations now work.

```python
>>> from transformers import VisionEncoderDecoderModel, BertConfig, BertGenerationDecoder, ViTHybridConfig, \
...     ViTHybridModel
>>> decoder = BertGenerationDecoder(BertConfig())
>>> encoder = ViTHybridModel(ViTHybridConfig())
>>> model = VisionEncoderDecoderModel(encoder=encoder, decoder=decoder)
>>>
>>> model
VisionEncoderDecoderModel(
  (encoder): ViTHybridModel(
    ...
  )
  (decoder): BertGenerationDecoder(
    ...
  )
)
```

```python
>>> from transformers import AutoModel
>>> model = AutoModel.from_pretrained("google/vit-hybrid-base-bit-384")
Some weights of ViTHybridModel were not initialized from the model checkpoint at google/vit-hybrid-base-bit-384 and are newly initialized: ['vit.pooler.dense.bias', 'vit.pooler.dense.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.

>>> model
ViTHybridModel(
    ...
)
```

---

Regarding the failing circle_ci tests, they seem unrelated and we should be good to go.

---

I have executed pytests on [Colab](https://colab.research.google.com/drive/1pDzL0STrA91h0K76MCqDScaUHLZY5yXt#scrollTo=nKOrm6xJMoQ1&line=1&uniqifier=1), and it looks good to me though some tests got skipped.

===================== 64 passed, 45 skipped, 28 warnings in 123.58s (0:02:03) ======================

Hi @kshitij98, thanks for digging into this! 

This is going to be quite tricky to resolve to make sure everything is backwards compatible. We're going to deprecate the vit hybrid model soon, as it has a relatively small number of downloads. In this case, I'd suggest we park this change and don't worry about trying to make this work. 

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.