enable memory tracker metrics for npu
Author: ji-huazhong
Pull request: yes

# What does this PR do?

As per title.


## 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?
- [ ] 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.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->

cc @amyeroberts


Comments:
Verified with the following test case.
```python
# spec.py
import torch
import torch_npu
# User can add additional imports here

# Specify the device name (eg. 'cuda', 'cpu')
DEVICE_NAME = 'npu:0'

# Specify device-specific backends to dispatch to.
# If not specified (i.e., `None`) will fallback to 'default' in 'testing_utils.py`
MANUAL_SEED_FN = torch.npu.manual_seed
EMPTY_CACHE_FN = torch.npu.empty_cache
DEVICE_COUNT_FN = torch.npu.device_count
```

```
(mem) [root@localhost mem]# RUN_SLOW=1 TRANSFORMERS_TEST_BACKEND="torch_npu"  TRANSFORMERS_TEST_DEVICE="npu:0" TRANSFORMERS_TEST_DEVICE_SPEC="spec.py" python -m pytest -sv tests/trainer/test_trainer.py::TrainerIntegrationTest::test_mem_metrics
============================================================================================================ test session starts ============================================================================================================
platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0 -- /root/miniconda3/envs/mem/bin/python
cachedir: .pytest_cache
rootdir: /home/w00668292/mem
configfile: setup.cfg
collected 1 item

  0%|                                                                                                                                                                                                                 | 0/24 [00:00<?, ?it/s]Could not estimate the number of tokens of the input, floating-point operations will not be computed
{'train_runtime': 0.9881, 'train_samples_per_second': 194.31, 'train_steps_per_second': 24.289, 'train_loss': 10.069827397664389, 'init_mem_cpu_alloc_delta': 0, 'init_mem_gpu_alloc_delta': 1024, 'init_mem_cpu_peaked_delta': 0, 'init_mem_gpu_peaked_delta': 0, 'train_mem_cpu_alloc_delta': 151519232, 'train_mem_gpu_alloc_delta': 4096, 'train_mem_cpu_peaked_delta': 0, 'train_mem_gpu_peaked_delta': 4608, 'before_init_mem_cpu': 1883963392, 'before_init_mem_gpu': 0, 'epoch': 3.0}
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 24/24 [00:01<00:00, 16.16it/s]
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 78.41it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 525.37it/s]
  0%|                                                                                                                                                                                                                 | 0/24 [00:00<?, ?it/s]Could not estimate the number of tokens of the input, floating-point operations will not be computed
{'train_runtime': 0.0769, 'train_samples_per_second': 2496.571, 'train_steps_per_second': 312.071, 'train_loss': 10.069827397664389, 'epoch': 3.0}
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 24/24 [00:00<00:00, 312.19it/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 1256.67it/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:00<00:00, 1005.98it/s]
PASSED

============================================================================================================= warnings summary ==============================================================================================================
../../../root/miniconda3/envs/mem/lib/python3.8/site-packages/_pytest/config/__init__.py:1373
  /root/miniconda3/envs/mem/lib/python3.8/site-packages/_pytest/config/__init__.py:1373: 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
======================================================================================================= 1 passed, 1 warning in 19.46s =======================================================================================================
(mem) [root@localhost mem]#
```

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