🚨 T5Gemma2 model structure
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Makes sure that the attn implementation is set to all sub-configs. The `config.encoder.text_config` was not getting its attn set because we aren't passing it to `PreTrainedModel.__init__`. We can't change the model structure without breaking so I manually re-added a call to `self.adjust_attn_implemetation` in modeling code

Also deleted `__setattr__`, not sure what is the reason behind having them. Composite configs usually don't need to force-set the same attr in all subconfigs magically


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

Will finish up in a while and ask for review

Somewhat related: If I train a T5GemmaEncoder, I end up with a repository like: https://huggingface.co/tomaarsen/t5gemma2-270m-gooaq-cmnrl/tree/main
Note that the `model_type` is `t5gemma2_encoder`, which I can't load with `AutoConfig` like other architectures. Perhaps I should still expand on #43559 to turn `t5gemma2_encoder` into an architecture with AutoConfig and AutoModel support? Otherwise I still can't conveniently load https://huggingface.co/tomaarsen/t5gemma2-270m-gooaq-cmnrl.

- Tom Aarsen

@tomaarsen yes, it's expected that `AutoConfig` will not work on the encoder-part. If it's needed for ST, we need the other PR you had as well. I was assuming ST will load directly with `T5GemmaEncoderConfig` in a similar fashion to old T5 family

> If it's needed for ST, we need the other PR you had as well.

Agreed, will re-add it. 

> I was assuming ST will load directly with `T5GemmaEncoderConfig` in a similar fashion to old T5 family

I will, but the old T5 family is also loaded with:
load AutoConfig -> Check config type -> Check for edge cases (T5, MT5, T5Gemma, T5Gemma2), otherwise AutoModel

And then I need to be able to use
```python
from transformers import AutoConfig

config = AutoConfig.from_pretrained("tomaarsen/t5gemma2-270m-gooaq-cmnrl")
```

- Tom Aarsen

Failing test is flaky, ready for review

run-slow: t5gemma2

This comment contains `run-slow`, running the specified jobs: 

models: ["models/t5gemma2"]
quantizations: []

run-slow: t5gemma2


run-slow: t5gemma2



## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/21628269544)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [705fc028](https://github.com/huggingface/transformers/commit/705fc02876fcd2b03fce052be55357f2dbe57fde) | merge commit |
| PR | [e98f4bc0](https://github.com/zucchini-nlp/transformers/commit/e98f4bc0e9561765e3f3b089a74f2eabee86d418) | branch commit |
| main | [b6a202f8](https://github.com/huggingface/transformers/commit/b6a202f868d261c7404d331cf9d8ce03aec12fe2) | base commit |

⚠️ No test being reported (jobs are skipped or cancelled)!


💔 This comment contains `run-slow`, but unknown error occurred and [the workflow run](https://github.com/huggingface/transformers/actions/runs/21629344467) aborted!

run-slow: t5gemma2

This comment contains `run-slow`, running the specified jobs: 

models: ["models/t5gemma2"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/21633072337)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [3aa9ea02](https://github.com/huggingface/transformers/commit/3aa9ea025f8b88c21fecb1bbc681aa3ffb4d190e) | merge commit |
| PR | [958df6e0](https://github.com/zucchini-nlp/transformers/commit/958df6e0e6f2f4cffc57b43f34a659d6c93c5330) | branch commit |
| main | [affcf459](https://github.com/huggingface/transformers/commit/affcf45994a8b356f96c2a58e88ed8d679e46539) | base commit |

✅ No failing test specific to this PR 🎉 👏 !


Checked with rebase, everything is still working and tests are passing. Will merge after CI turns green

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: t5gemma, t5gemma2