code: def _maybe_wrap_formatter(formatter):
      if is_string_like(formatter):
          return lambda x: formatter.format(x)
      elif callable(formatter):
          return formatter
      else:
          msg = (
              "Expected a template string or callable, got {formatter} "
              "instead".format(formatter=formatter)
          )
          raise TypeError(msg)
  
imports: from collections import defaultdict
  from contextlib import contextmanager
  import copy
  from functools import partial
  from itertools import product
  from uuid import uuid1
  import numpy
  from pandas.compat import range
  from pandas.util._decorators import Appender
  from pandas.core.dtypes.common import is_float, is_string_like
  from pandas.core.dtypes.generic import ABCSeries
  import pandas
  from pandas.api.types import is_dict_like, is_list_like
  import pandas.core.common
  from pandas.core.config import get_option
  from pandas.core.generic import _shared_docs
  from pandas.core.indexing import _maybe_numeric_slice, _non_reducing_slice
label_desc: Use image node_id 4 for calling a global function with example usage: _maybe_wrap_formatter(formatter) and returns: function, formatter