docstr: Ensure provided `f` is a valid callable
  
  Parameters
  ----------
  f: Callable, string, None
      See `metric_function` documentation of :meth:`Metric.__init__`
  
  Returns
  -------
  Callable
      A function derived from `f` if `f` was not already callable. Else `f`
docstr_tok: ["Ensure","provided","`","f","`","is","a","valid","callable","Parameters","--","--","--","--","--","f",":","Callable",",","string",",","None","See","`","metric_function","`","documentation","of",":","meth",":","`","Metric.__init__","`","Returns","--","--","--","-","Callable","A","function","derived","from","`","f","`","if","`","f","`","was","not","already","callable",".","Else","`","f","`"]
code: def _set_metric_function(self, f):
      """Ensure provided `f` is a valid callable
  
      Parameters
      ----------
      f: Callable, string, None
          See `metric_function` documentation of :meth:`Metric.__init__`
  
      Returns
      -------
      Callable
          A function derived from `f` if `f` was not already callable. Else `f`
      """
      if not callable(f):
          # Try to find a function of given name in `sklearn.metrics`
          try:
              return sk_metrics.__getattribute__(
                  self.name if f is None else f
              )
          except AttributeError:
              raise AttributeError(
                  f"`sklearn.metrics` has no attribute: {f or self.name}"
              )
      return f
  
imports: from collections import OrderedDict
  from contextlib import suppress
  import numpy
  import pandas
  from typing import Dict, Iterable, List, Tuple, Union
  from sklearn import metrics
  from sklearn.utils.multiclass import type_of_target, unique_labels
label_desc: Use image node_id 5 for calling the Metric obj's underlying member method code with example usage: obj._set_metric_function(f) and returns: f, sk_metrics