speed up Nezha model tests
Author: sijunhe
Pull request: yes

# What does this PR do?

This PR speeds up Nezha tests, which was pointed out by @sgugger to be slow. On my machine, this change speeds up the test by about 80% (~160s -> ~20s). I think we should merge this instead of #18103.
<!-- Remove if not applicable -->

Fixes #18103


## 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#start-contributing-pull-requests),
      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.
- [ ] 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.

@sgugger @LysandreJik 

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Thanks @sijunhe, I can confirm that this does significantly speed up the tests:

```
slowest durations
5.00s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_torch_fx_output_loss
4.70s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_torch_fx
3.61s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_model_outputs_equivalence
1.71s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_attention_outputs
1.69s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_save_load_fast_init_to_base
1.68s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_save_load_fast_init_from_base
1.06s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_training
1.03s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_head_pruning_integration
0.95s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_save_load
0.90s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_head_pruning_save_load_from_pretrained
0.83s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_feed_forward_chunking
0.77s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_correct_missing_keys
0.74s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_hidden_states_output
0.56s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_load_with_mismatched_shapes
0.53s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_training_gradient_checkpointing
0.51s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_resize_tokens_embeddings
0.47s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_headmasking
0.46s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_tie_model_weights
0.45s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_head_pruning_save_load_from_config_init
0.45s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_forward_signature
0.43s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_head_pruning
0.43s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_save_load_keys_to_ignore_on_save
0.42s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_determinism
0.41s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_gradient_checkpointing_backward_compatibility
0.39s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_inputs_embeds
0.39s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_resize_embeddings_untied
0.38s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_gradient_checkpointing_enable_disable
0.36s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_initialization
0.35s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_model_common_attributes
0.18s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_problem_types
0.11s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_model_as_decoder
0.10s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_model_as_decoder_with_default_input_mask
0.06s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_model
0.06s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_for_masked_lm
0.05s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_for_sequence_classification
0.05s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_for_multiple_choice
0.05s call     tests/models/nezha/test_modeling_nezha.py::NezhaModelTest::test_retain_grad_hidden_states_attentions
```



Thanks for fixing them!