code: def register_metric(metric_name: str) -> Callable[..., Any]:
      """Decorator for metric registration."""
  
      def decorate(fn):
          fn_name = fn.__module__ + ":" + fn.__name__
          if (
              metric_name in _REGISTRY
              and _REGISTRY[metric_name] != fn_name
          ):
              log.warning(
                  '"{}" is already registered as a metric name, the old function will be ignored'.format(
                      metric_name
                  )
              )
          _REGISTRY[metric_name] = fn_name
          return fn
  
      return decorate
  
file_path: DeepPavlov/deeppavlov/core/common/metrics_registry.py
imports: import importlib
  import json
  from logging import getLogger
  from pathlib import Path
  from typing import Callable, Any
  from deeppavlov.core.common.errors import ConfigError
label_desc: Use image node_id 2 for calling a global function with example usage: register_metric(metric_name) and returns: decorate, fn