Fix TF loading PT safetensors when weights are tied
Author: Rocketknight1
Pull request: yes

This PR resolves issues when loading PT safetensors files in TF.

The cause of the problem was that safetensors saving discards "aliased" tensors, weight tensors that share the same underlying weight array. This commonly occurs when models use tied weights. Many of our TF models don't support weight tying, however, and as a result the decoder output weights fail to load correctly.

The solution is to use a trick we already use for encoder-decoder models, a model-specific `tf_to_pt_weight_rename` method. This PR refactors the way that method is called to make it more accessible (no more need to override `from_pretrained`), and adds `tf_to_pt_weight_rename` methods to the affected models.

However, I suspect there are more affected models which aren't showing up in this test, because the only models failing in this test are the models that **always use weight tying without needing a config flag**. If a model **optionally** ties weights based on a flag, that flag will not be set in this test. I suspect the same fix will be needed for several more models as a result, even though this test doesn't flag them.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_27490). All of your documentation changes will be reflected on that endpoint.

Update: I tried to get the test to trigger other models by adding `config.tie_word_embeddings=True`, but everything still seems to be passing, so I guess this PR is ready for review! cc @ArthurZucker or @amyeroberts 

Added your suggestion @amyeroberts! The method always returns a tuple now.

Quick ping again for final approval @amyeroberts !

Before merge, let's check this PR agains the Hub Repo: `"facebook/bart-large-cnn"`, say by running 

`tests/models/bart/test_modeling_tf_bart.py::TFBartModelIntegrationTest::test_cnn_summarization_same_as_fairseq_hard`

@ydshieh - good spot! I missed adding this method for BART. I tested and the slow tests that are failing in the CI are passing now that I've added it.

Thanks a lot, @Rocketknight1 . The `TFBartModelIntegrationTest` all pass now with this PR.

However, for `TFRag` still have 5 failing tests (as on the slack report)
```
FAILED tests/models/rag/test_modeling_tf_rag.py::TFRagModelIntegrationTests::test_rag_sequence_inference - ValueError: Weight name final_logits_bias:0 does not start with name_scope tf_rag_sequence_for_generation_1/rag. This is an internal error in Transformers, so (unless you were doing something really evil) please open an...

FAILED tests/models/rag/test_modeling_tf_rag.py::TFRagModelIntegrationTests::test_rag_token_inference - ValueError: Weight name final_logits_bias:0 does not start with name_scope tf_rag_token_for_generation_1/rag. This is an internal error in Transformers, so (unless you were doing something really evil) please open an issue...

FAILED tests/models/rag/test_modeling_tf_rag.py::TFRagModelIntegrationTests::test_rag_token_inference_save_pretrained - ValueError: Weight name final_logits_bias:0 does not start with name_scope tf_rag_token_for_generation_1/rag. This is an internal error in Transformers, so (unless you were doing something really evil) plea...

FAILED tests/models/rag/test_modeling_tf_rag.py::TFRagModelSaveLoadTests::test_rag_sequence_from_pretrained - ValueError: Weight name final_logits_bias:0 does not start with name_scope tf_rag_sequence_for_generation_1/rag. This is an internal error in Transformers, so (unless you were doing something really evil) please open...

FAILED tests/models/rag/test_modeling_tf_rag.py::TFRagModelSaveLoadTests::test_rag_token_from_pretrained - ValueError: Weight name final_logits_bias:0 does not start with name_scope tf_rag_token_for_generation_1/rag. This is an internal error in Transformers, so (unless you were doing something really evil) please open an is...


```

@ydshieh noted! I think I'll need a separate PR for those, though, since it's a composite model. This PR should fix most models, though - can we merge it urgently before the release while I work on something to fix models like RAG?

@LysandreJik yes, will do! I think this will synergize with the new weight building #27794 as well, and we should be able to get TF-safetensors in good shape soon.