code: def _space_for_func(func_name, func_args, flag_name, flag_val):
      func_name = func_name or "uniform"
      try:
          space_init = getattr(hyperopt.hp, func_name)
      except AttributeError:
          log.error(
              "unsupported flag function used in %s=%s",
              flag_name,
              flag_val,
          )
          raise SystemExit(1)
      else:
          try:
              space = space_init(flag_name, *func_args)
              hyperopt.pyll.stochastic.sample(space)
          except Exception as e:
              log.error(
                  "invalid flag function used in %s=%s: %s",
                  flag_name,
                  flag_val,
                  e,
              )
              raise SystemExit(1)
          else:
              return space
  
file_path: guildai/examples/hyperopt/tpe.py
imports: import logging
  from guild import batch_util
  from guild import flag_util
  from guild import index
  import numpy
  import hyperopt
label_desc: Use image node_id 5 for calling a global function with example usage: _space_for_func(func_name, func_args, flag_name, flag_val) and returns: space