Refactor initialization tests to check init from `from_pretrained`
Author: amyeroberts
Pull request: yes

# What does this PR do?

Adds a new test which checks that all model weights are correctly initialized when creating a model using `from_pretrained`. This was done by: 
*  Adding a new `test_initialization_from_pretrained` test
* Abstraction out the common logic between `test_initialization_from_pretrained` and  `test_initialization` into `_test_models_weight_initialization`

## Motivation

A weight init bug in CLIP was highlighted in #30374. 

When a model is created via a config, the layer weights are initialized with their default torch initialization i.e. with `parameter.reset_parameters()`. 

When a model is created with a checkpoint using `from_pretrained`, the [model weights are not initialized](https://github.com/huggingface/transformers/blob/416fdbad7a79e6b6875fa9384a9f4408ef179742/src/transformers/modeling_utils.py#L3535), and are instead `torch.empty` arrays. This is to speed up model creation: there's no need to initialize if we're going to use the checkpoint's weight. 

However, if the weight isn't in the checkpoint and doesn't have init behaviour specified in the model's `_init_weight` method, then the weight will remain empty. 

This can be tricky to catch if only part of the layer's weights are initialized. For example, in CLIP, [the bias initialization is specified](https://github.com/huggingface/transformers/blob/9a4a119c10bde6a19e45f0a2cf01e9a860c75450/src/transformers/models/clip/modeling_clip.py#L458) but not the `weight`. This means the Linear module [will be marked as initialized](https://github.com/huggingface/transformers/blob/416fdbad7a79e6b6875fa9384a9f4408ef179742/src/transformers/modeling_utils.py#L1710) even if this is partly True. 

The initialization bug wasn't caught in our test suite, despite test_initialization, because [this test creates the model from the config](https://github.com/huggingface/transformers/blob/9a4a119c10bde6a19e45f0a2cf01e9a860c75450/tests/test_modeling_common.py#L633), not from a checkpoint. 

As this is difficult to correctly handle within the code itself, I propose adding a test which will at least catch when weights aren't properly covered in the `from_pretrained` scenario


## 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?
- [ ] 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.
- [ ] 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?

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

I had an idea that it could be useful (but potentially overkill) for some tests to do something along the lines of the "no_init" context trick, but changing it to initialize all the weights as NaNs. It would then be easier to detect weights that were not initialized. It is very possible that this suggestion is not applicable / not useful - feel free to ignore ☺️.

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.