code: def _check_distance_function(metric):
      """Check distance function."""
      if isinstance(metric, str):
          if metric not in distance_functions.keys():
              raise ValueError(f"Unknown distance metric '{metric}'")
          else:
              metric = distance_functions[metric]
      elif not hasattr(metric, "__call__"):
          raise ValueError(
              "Distance metric must be a function or a string "
              f"(Got {type(metric)}."
          )
      return metric
  
imports: import numpy
  from scipy.linalg import eigvalsh, solve
  from sklearn.metrics import euclidean_distances
  from .base import logm, sqrtm, invsqrtm
label_desc: Use image node_id 12 for calling a global function with example usage: _check_distance_function(metric) and returns: metric