code: def is_one_of_factory(legal_values):
      callables = [c for c in legal_values if callable(c)]
      legal_values = [c for c in legal_values if not callable(c)]
  
      def inner(x):
          from pandas.io.formats.printing import pprint_thing as pp
  
          if x not in legal_values:
              if not any(c(x) for c in callables):
                  pp_values = pp("|".join(lmap(pp, legal_values)))
                  msg = "Value must be one of {pp_values}"
                  if len(callables):
                      msg += " or a callable"
                  raise ValueError(msg.format(pp_values=pp_values))
  
      return inner
  
imports: from collections import namedtuple
  from contextlib import contextmanager
  import re
  import warnings
  import pandas.compat
  from pandas.compat import lmap, map, u
label_desc: Use image node_id 21 for calling a global function with example usage: is_one_of_factory(legal_values) and returns: inner