code: def register_custom_metric(
      custom_metric_path: PathOrStr, custom_metric_name: str
  ):
      """
      Import, load, and register the custom metric function from the given path.
  
      Parameters
      ----------
      custom_metric_path : :class:`skll.types.PathOrStr`
          The path to a custom metric.
      custom_metric_name : str
          The name of the custom metric function to load. This function must take
          only two array-like arguments: the true labels and the predictions,
          in that order.
  
      Raises
      ------
      ValueError
          If the custom metric path does not end in '.py'.
      NameError
          If the name of the custom metric file conflicts
          with an already existing attribute in ``skll.metrics``
          or if the custom metric name conflicts with a scikit-learn
          or SKLL metric.
      """
      if not custom_metric_path:
          raise ValueError(
              f"custom metric path was not set and "
              f"metric {custom_metric_name} was not found."
          )
  
      custom_metric_path = Path(custom_metric_path)
      if not custom_metric_path.exists():
          raise ValueError(
              f"custom metric path '{custom_metric_path}' "
              f"does not exist."
          )
  
      if custom_metric_path.suffix != ".py":
          raise ValueError(
              f"custom metric path must end in .py, you specified "
              f"{custom_metric_path}"
          )
  
      # get the name of the module containing the custom metric
      custom_metric_module_name = custom_metric_path.stem
  
      # once we know that the module name is okay, we need to make sure
      # that the metric function name is also okay
      if (
          custom_metric_name in get_scorer_names()
          or custom_metric_name in _CUSTOM_METRICS
      ):
          raise NameError(
              f"a metric called '{custom_metric_name}' already "
              f"exists; rename the metric function in "
              f"{custom_metric_module_name}.py and try again."
          )
  
      # dynamically import the module unless we have already done it
      if custom_metric_module_name not in sys.modules:
          sys.path.append(str(custom_metric_path.resolve().parent))
          metric_module = import_module(custom_metric_module_name)
  
          # this statement is only necessary so that if we end
          # up using multiprocessing parallelization backend,
          # things are serialized properly
          globals()[custom_metric_module_name] = metric_module
  
      # get the metric function from this imported module
      metric_func = getattr(
          sys.modules[custom_metric_module_name], custom_metric_name
      )
      # again, we need this for multiprocessing serialization
      metric_func.__module__ = (
          f"skll.metrics.{custom_metric_module_name}"
      )
  
      # extract any "special" keyword arguments from the metric function
      metric_func_parameters = signature(metric_func).parameters
      make_scorer_kwargs = {}
      for make_scorer_kwarg in [
          "greater_is_better",
          "needs_proba",
          "needs_threshold",
      ]:
          if make_scorer_kwarg in metric_func_parameters:
              parameter = metric_func_parameters.get(make_scorer_kwarg)
              if parameter is not None:
                  parameter_value = parameter.default
                  make_scorer_kwargs.update(
                      {make_scorer_kwarg: parameter_value}
                  )
  
      # make the scorer function with the extracted keyword arguments
      _CUSTOM_METRICS[f"{custom_metric_name}"] = make_scorer(
          metric_func, **make_scorer_kwargs
      )
  
      return metric_func
  
file_path: skll/skll/metrics.py
imports: import copy
  import sys
  from importlib import import_module
  from inspect import signature
  from pathlib import Path
  from typing import Optional, Union
  import numpy
  from scipy.stats import kendalltau, pearsonr, spearmanr
  from sklearn.metrics import confusion_matrix, f1_score, fbeta_score, get_scorer, get_scorer_names, make_scorer
  from skll.types import PathOrStr
label_desc: Use image node_id 4 for calling a global function with example usage: register_custom_metric(custom_metric_path, custom_metric_name) and returns: metric_func