Refactor embedding input/output getter/setter
Author: molbap
Pull request: yes
Labels: name: Core: Modeling

# What does this PR do?

**TL;DR**

`PreTrainedModel` now mixes in `EmbeddingAccessMixin` providing default
`get_input_embeddings` / `set_input_embeddings` / `get_output_embeddings` / `set_output_embeddings`  for all models. These methods should be removed from the codebase unless exceptionally weird.

## Details 

Uses a new attribute `__input_embed_layer = "embed_tokens"` by default, and one can change it to set which layer the embeddings should be gotten/set to. Then, assuming `embed_tokens` is that layer for instance, resolution order is

- self.model.embed_tokens
- self.embed_tokens
- delegate once via base_model_prefix
- else raise (model must override)

get_output_embeddings now auto-returns lm_head only if input embeddings
resolve (so pure audio/vision backbones still return None).

What you usually have to do: **nothing**. 

Override only if:

- embeddings live under a different attribute
- multiple embedding tables
- you need to hide an lm_head (override get_output_embeddings retunring None)
- helper head without token embeddings but still wants tying (override and return the head)

Potential breakages:
- Exotic layouts with custom embedding attr names (must override)

cc @vasqu @zucchini-nlp, minor but to remember for composite models too


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

Down to a few tests failing because of audio embeddings exceptions mostly, solving, then adding set_ and get_ encoder methods and merging this 

Tests pass! Some legacy models were difficult :grimacing: cc @ArthurZucker 
ESM has crossed modeling imports and that was a bit confusing haha. Should be OK to merge, failing test unrelated.


`PreTrainedModel` now mixes in `EmbeddingAccessMixin` providing default
`get_input_embeddings / set_input_embeddings / get_output_embeddings / set_output_embeddings`.

Default resolution order (input):
1. `self.model.embed_tokens`
2. `self.embed_tokens`
3. delegate once via `base_model_prefix`
4. else raise (model must override)

`get_output_embeddings` now auto-returns `lm_head` **only if** input embeddings
resolve (so pure audio/vision backbones still return `None`).

What you usually have to do: **nothing**. 

Override only if:
- embeddings live under a different attribute
- multiple embedding tables
- you need to *hide* an `lm_head` (override `get_output_embeddings` retunring `None`)
- helper head without token embeddings but still wants tying (override and return the head)

Potential breakage:

- Exotic layouts with custom embedding attr names (must override)

Everything else keeps working (resize, tie, generation) it looks like. :broom: :broom: 

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

run-slow: arcee, aria, aya_vision, bamba, bark, bart, beit, bigbird_pegasus, biogpt, bitnet, blenderbot, blenderbot_small, bloom, chameleon, clvp, codegen

run-slow: beit, bark, bart, clvp, glm4, glm4_moe, zamba2

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

models: ['models/bark', 'models/bart', 'models/beit', 'models/clvp', 'models/glm4', 'models/glm4_moe', 'models/zamba2']
quantizations: [] ...

Tested on a few slow models, failings are identical to `main`. Merging and keeping an eye out.