code: def format_objective(
      objective: Union[
          Text,
          oracle_module.Objective,
          List[Union[Text, oracle_module.Objective]],
      ],
      direction: Optional[Text] = None,
  ) -> List[oracle_module.Objective]:
      """Formats objective to a list of oracle_module.Objective.
  
      Args:
          objective: If a string, the direction of the optimization (min or max)
              will be inferred.
          direction: Optional. e.g. 'min' or 'max'.
  
      Returns:
          A list of oracle_module.Objective.
  
      Raises:
          TypeError: indicates wrong objective format.
      """
      if isinstance(objective, oracle_module.Objective):
          return [objective]
      if isinstance(objective, str):
          if direction:
              return [oracle_module.Objective(objective, direction)]
          return [
              oracle_module.Objective(
                  objective,
                  metrics_tracking.infer_metric_direction(objective),
              )
          ]
      if isinstance(objective, list):
          if isinstance(objective[0], oracle_module.Objective):
              return objective
          if isinstance(objective[0], str):
              return [
                  oracle_module.Objective(
                      m, metrics_tracking.infer_metric_direction(m)
                  )
                  for m in objective
              ]
      raise TypeError(
          "Objective should be either string or oracle_module.Objective, "
          "found {}".format(objective)
      )
  
imports: from typing import Any, Dict, List, Optional, Text, Union
  from keras_tuner.engine import hyperparameters
  from keras_tuner.engine import metrics_tracking
  from keras_tuner.engine import oracle
  from keras_tuner.engine import trial
  import numpy
  from tensorboard.plugins.hparams import api
label_desc: Use image node_id 7 for calling a global function with example usage: format_objective(objective, direction) and returns: list, list, list, objective, unknown