Make static cache compatible with torch.export
Author: guangy10
Pull request: yes

# What does this PR do?

This PR is to make the static cache impl compatible with both `torch.compile()` and [`torch.export()`](https://pytorch.org/docs/stable/export.html) (new). Making a model exportable so that it can be further lowered and run on edge devices through [**ExecuTorch**](https://pytorch.org/executorch/main/index.html), which is a native PyTorch framework for on-device inference.

An example of lower Gemma-2b to ExecuTorch using it can be found in #31706.


## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? 
      It's discussed in the XNF meeting.
- [x] Did you write any new necessary tests?
     Added an unit test to ensure the static cache is exportable.
     Also have an e2e test to showcase the new functionalities of using Hugging Face models in the demo PR #31706.
     
     
## 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.

@ArthurZucker @amyeroberts

Comments:
make fixup

cc @gante too 

`pytest tests/utils/test_cache_utils.py -v` passed from local run.
```
============================================================================= test session starts ==============================================================================
platform linux -- Python 3.10.0, pytest-7.4.1, pluggy-1.3.0 -- /home/guangyang/.conda/envs/executorch/bin/python3.10
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/guangyang/transformers/.hypothesis/examples')
rootdir: /home/guangyang/transformers
configfile: pyproject.toml
plugins: hypothesis-6.84.2, xdist-3.3.1, anyio-4.4.0
collected 20 items

tests/utils/test_cache_utils.py::CacheTest::test_dynamic_cache_retrocompatibility PASSED                                                                                 [  5%]
tests/utils/test_cache_utils.py::CacheTest::test_reorder_cache_retrocompatibility PASSED                                                                                 [ 10%]
tests/utils/test_cache_utils.py::CacheTest::test_static_cache_exportability PASSED                                                                                       [ 15%]
tests/utils/test_cache_utils.py::CacheTest::test_static_cache_mha_mqa_gqa PASSED                                                                                         [ 20%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_dynamic_cache_batched SKIPPED (test requires CUDA)                                                           [ 25%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_dynamic_cache_beam_search SKIPPED (test requires CUDA)                                                       [ 30%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_dynamic_cache_extra_left_padding SKIPPED (test requires CUDA)                                                [ 35%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_dynamic_cache_hard SKIPPED (test requires CUDA)                                                              [ 40%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_sink_cache_hard SKIPPED (test requires CUDA)                                                                 [ 45%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_sink_cache_iterative_prompts SKIPPED (test requires CUDA)                                                    [ 50%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_beam_search SKIPPED (test requires CUDA)                                                        [ 55%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_extra_left_padding SKIPPED (test requires CUDA)                                                 [ 60%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_left SKIPPED (test requires CUDA)                                           [ 65%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_left_0_eager SKIPPED (test requires CUDA)                                   [ 70%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_left_1_sdpa SKIPPED (test requires CUDA)                                    [ 75%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_left_2_flash_attention_2 SKIPPED (test requires CUDA)                       [ 80%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_right SKIPPED (test requires CUDA)                                          [ 85%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_right_0_eager SKIPPED (test requires CUDA)                                  [ 90%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_right_1_sdpa SKIPPED (test requires CUDA)                                   [ 95%]
tests/utils/test_cache_utils.py::CacheIntegrationTest::test_static_cache_greedy_decoding_pad_right_2_flash_attention_2 SKIPPED (test requires CUDA)                      [100%]

=============================================================================== warnings summary ===============================================================================
../.conda/envs/executorch/lib/python3.10/site-packages/_pytest/config/__init__.py:1376
  /home/guangyang/.conda/envs/executorch/lib/python3.10/site-packages/_pytest/config/__init__.py:1376: PytestConfigWarning: Unknown config option: doctest_glob

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================== 4 passed, 16 skipped, 1 warning in 14.13s ===================================================================
```

Will need some guidance to resolve the permission issue in the CI. cc: @amyeroberts @gante 

(as replied on slack -- CI can be fixed by applying the `@require_read_token` decorator on the failing test)

All comments addressed. Should be ready to go! 🚀

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

Resolved merge conflicts. @amyeroberts @gante @ArthurZucker thank you for the feedback ❤️!