code: def _option_or_path(options, regex=CUSTOM_CLASS_REGEX):
      def type_check(s):
          # first, check whether the argument is one of the preconfigured options
          if s in list(options):
              return s
  
          # otherwise, check it against the regex, and try to pull out a path to a
          # real file. The regex must extract the path to the file as groups()[0].
          match = re.match(regex, s)
          if match and os.path.isfile(match.groups()[0]):
              return s
  
          # if both of those fail, there's something wrong
          raise argparse.ArgumentTypeError(
              "{} is not a valid option or path!".format(s)
          )
  
      return type_check
  
imports: from __future__ import absolute_import, unicode_literals
  import argparse
  import os
  import re
  from builtins import object, str
  import yaml
  from atm.constants import BUDGET_TYPES, CUSTOM_CLASS_REGEX, JSON_REGEX, METHODS, METRICS, SCORE_TARGETS, SELECTORS, SQL_DIALECTS, TIME_FMT, TUNERS
label_desc: Use image node_id 1 for calling a global function with example usage: _option_or_path(options, regex) and returns: type_check, s, s