Add T5 GGUF loading support
Author: junejae
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 -->

Add T5 GGUF loading support

Due to the nature of T5's architecture, I decided to replicate [gguf's](https://github.com/ggerganov/llama.cpp/blob/54f376d0b92c6ff6feb1fa2ef8ed2022348100ba/convert_hf_to_gguf.py#L178) conversion [logic](https://github.com/ggerganov/llama.cpp/blob/4db04784f96757d74f74c8c110c2a00d55e33514/gguf-py/gguf/tensor_mapping.py#L568), so the final code gets messy.
I tried to avoid any logical conflicts between t5's and existing model architectures, but feel free to edit codes if you find any mistakes that I haven't noticed out.


## 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. Link: https://github.com/huggingface/transformers/issues/33260
- [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).
- [x] 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.

@SunMarc @LysandreJik @ArthurZucker , could you please review this 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:

- text models: @ArthurZucker
- vision models: @amyeroberts, @qubvel
- speech models: @ylacombe, @eustlb
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc

Documentation: @stevhliu

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

 -->


Comments:
Does your code allow loading T5 Encoder XXL (the one used in Flux)? 
Example files here:
https://huggingface.co/city96/t5-v1_1-xxl-encoder-gguf/tree/main

@bonlime Yes, it works with AutoModelForTextEncoding class. I've tested with T5 encoder of the exact repo you linked, but I didn't commit the independent test code block for T5 encoder since the code could be dirty with embedding vector style example output.

@SunMarc
I've resolved conflicts and added more tests. Could you please review it again?

Make sure to fix the CI also ! 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33389). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Is the commit merged? I still get the error:

ValueError: GGUF model with architecture t5encoder is not supported yet.

```
t5_gguf = 'city96/t5-v1_1-xxl-encoder-gguf'
t5_file = 't5-v1_1-xxl-encoder-Q8_0.gguf'

text_encoder_2 = T5EncoderModel.from_pretrained(
    t5_gguf,
    gguf_file=t5_file,
    torch_dtype=torch.bfloat16,
)
```

cc @Isotr0py 

Pls, add this example into comments into UMT5EncoderModel's code
Using from_pretrained except from_single_file was new for me

> Is the commit merged? I still get the error:
> 
> ValueError: GGUF model with architecture t5encoder is not supported yet.
> 
> ```
> t5_gguf = 'city96/t5-v1_1-xxl-encoder-gguf'
> t5_file = 't5-v1_1-xxl-encoder-Q8_0.gguf'
> 
> text_encoder_2 = T5EncoderModel.from_pretrained(
>     t5_gguf,
>     gguf_file=t5_file,
>     torch_dtype=torch.bfloat16,
> )
> ```



too slow😭.
need to convert first 
Converting and de-quantizing GGUF tensors...: 100%|██████████████████████████████████████████████████████| 219/219 [00:56<00:00,  3.89it/s]

Yeah, we need to make this multi-threaded to go faster ;D 

comfyui is much faster, don't need to convert in each running.For some reason,i have to test gguf in diffusers😄