code: def create_objective(objective):
      if objective is None:
          return DefaultObjective()
      if isinstance(objective, list):
          return MultiObjective(
              [create_objective(obj) for obj in objective]
          )
      if isinstance(objective, Objective):
          return objective
      if not isinstance(objective, str):
          raise TypeError(
              "`objective` not understood, expected str or "
              f"`Objective` object, found: {objective}"
          )
  
      direction = metrics_tracking.infer_metric_direction(objective)
      if direction is None:
          error_msg = (
              'Could not infer optimization direction ("min" or "max") '
              'for unknown metric "{obj}". Please specify the objective  as'
              "a `keras_tuner.Objective`, for example `keras_tuner.Objective("
              '"{obj}", direction="min")`.'
          )
          error_msg = error_msg.format(obj=objective)
          raise ValueError(error_msg)
      return Objective(name=objective, direction=direction)
  
imports: from keras_tuner.api_export import keras_tuner_export
  from keras_tuner.engine import metrics_tracking
label_desc: Use image node_id 1 for calling a global function with example usage: create_objective(objective) and returns: Objective, DefaultObjective, MultiObjective, objective