Another metric with the same name already exists.
Hi, i'm struggling to use pipeline module from transformers following the installation guide in this repo, maybe i'm doing something wrong and someone can help me. 

## Environment info
Tried to run 'transformers-cli env' and got same error i'm trying to report:

```
2021-11-03 23:43:42.958058: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-11-03 23:43:42.958079: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-11-03 23:43:43.680663: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers
Traceback (most recent call last):
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/file_utils.py", line 2147, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/modeling_tf_utils.py", line 637, in <module>
    class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, PushToHubMixin):
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/tensorflow/python/util/lazy_loader.py", line 62, in __getattr__
    module = self._load()
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/tensorflow/python/util/lazy_loader.py", line 45, in _load
    module = importlib.import_module(self.__name__)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/__init__.py", line 25, in <module>
    from keras import models
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/models.py", line 20, in <module>
    from keras import metrics as metrics_module
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/metrics.py", line 24, in <module>
    from keras import activations
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/activations.py", line 20, in <module>
    from keras.layers import advanced_activations
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/layers/__init__.py", line 23, in <module>
    from keras.engine.input_layer import Input
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/engine/input_layer.py", line 21, in <module>
    from keras.engine import base_layer
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/engine/base_layer.py", line 43, in <module>
    from keras.mixed_precision import loss_scale_optimizer
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/mixed_precision/loss_scale_optimizer.py", line 18, in <module>
    from keras import optimizers
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/optimizers.py", line 31, in <module>
    from keras.optimizer_v2 import adadelta as adadelta_v2
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/optimizer_v2/adadelta.py", line 22, in <module>
    from keras.optimizer_v2 import optimizer_v2
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/keras/optimizer_v2/optimizer_v2.py", line 36, in <module>
    keras_optimizers_gauge = tf.__internal__.monitoring.BoolGauge(
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/tensorflow/python/eager/monitoring.py", line 360, in __init__
    super(BoolGauge, self).__init__('BoolGauge', _bool_gauge_methods,
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/tensorflow/python/eager/monitoring.py", line 135, in __init__
    self._metric = self._metric_methods[self._label_length].create(*args)
tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ramirom/workspace/testTensor/env/bin/transformers-cli", line 5, in <module>
    from transformers.commands.transformers_cli import main
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/commands/transformers_cli.py", line 23, in <module>
    from .run import RunCommand
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/commands/run.py", line 17, in <module>
    from ..pipelines import SUPPORTED_TASKS, TASK_ALIASES, Pipeline, PipelineDataFormat, pipeline
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/pipelines/__init__.py", line 25, in <module>
    from ..models.auto.configuration_auto import AutoConfig
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/models/__init__.py", line 19, in <module>
    from . import (
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/models/layoutlm/__init__.py", line 22, in <module>
    from .configuration_layoutlm import LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP, LayoutLMConfig
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/models/layoutlm/configuration_layoutlm.py", line 22, in <module>
    from ...onnx import OnnxConfig, PatchingSpec
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/onnx/__init__.py", line 17, in <module>
    from .convert import export, validate_model_outputs
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/onnx/convert.py", line 23, in <module>
    from .. import PreTrainedModel, PreTrainedTokenizer, TensorType, TFPreTrainedModel, is_torch_available
  File "<frozen importlib._bootstrap>", line 1039, in _handle_fromlist
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/file_utils.py", line 2137, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/file_utils.py", line 2149, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.modeling_tf_utils because of the following error (look up to see its traceback):
Another metric with the same name already exists.

```
- `transformers` version: 4.13.0.dev0 and tried 4.12.0 and same error
- Platform: Ubuntu 20.04.3 LTS
- Python version: Python 3.8.10
- PyTorch version (GPU?): none
- Tensorflow version (GPU?): tensorflow 2.6.1
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

## Information

Model I am using (Bert, XLNet ...): I'm just importing pipeline from transformers.

The problem arises when using:
* [*] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

## To reproduce

Steps to reproduce the behavior:

I start from a clean pip environment
1. install tensorflow following installation page instructions
```
# Requires the latest pip
pip install --upgrade pip

# Current stable release for CPU and GPU
pip install tensorflow
```
2. install transformers following installation instruction:
`pip install transformers`
3. create a python script (test.py) and do: 
`from transformers import pipeline
`
4. run:
`python3 test.py`
5. i got the following error:
`Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from transformers import pipeline
  File "<frozen importlib._bootstrap>", line 1039, in _handle_fromlist
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/file_utils.py", line 2137, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/ramirom/workspace/testTensor/env/lib/python3.8/site-packages/transformers/file_utils.py", line 2149, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
Failed to import transformers.modeling_tf_utils because of the following error (look up to see its traceback):
Another metric with the same name already exists.`
## Expected behavior
I expect no error when just importing pipeline

I've experienced the same problem, switching to an earlier version of tensorflow (2.5 instead of 2.6) seems to have solved it for me.
There seems to be some issue with 2.6 version right now according to this thread: #14265 <|||||>Just FYI: the underlying problem actually seems to come from keras 2.7 after some investigation: https://github.com/keras-team/keras/issues/15585

_meaning installing `keras==2.6.0` should solve the problem_<|||||>That did the trick, amazing. Thanks for the quick response!! <|||||>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/master/CONTRIBUTING.md) are likely to be ignored.<|||||>Hey @RamiroMoreira given the solution provided by @frgfm can we close this issue?<|||||>Yes, thank you!