code: def _objective_fn(batch):
      obj_scalar, obj_negate = batch_util.objective_scalar(batch)
  
      def fn(trial_flags):
          run = batch_util.run_trial(batch, trial_flags)
          obj_value = index.scalars(run).get(obj_scalar)
          if obj_value is None:
              log.error(
                  "Trial %s did not log objective '%s' - cannot use to optimize",
                  run.id,
                  obj_scalar,
              )
              return {
                  "status": hyperopt.STATUS_FAIL,
              }
          return {
              "status": hyperopt.STATUS_OK,
              "loss": obj_value * obj_negate,
              "run": run,
          }
  
      return fn
  
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 2 for calling a global function with example usage: _objective_fn(batch) and returns: fn, dict, dict