code: def _maybe_infer_direction_from_objective(objective, metric_name):
      if isinstance(objective, obj_module.Objective):
          objective = [objective]
      return next(
          (
              obj.direction
              for obj in objective
              if obj.name == metric_name
          ),
          None,
      )
  
imports: import collections
  import hashlib
  import os
  import random
  import threading
  import warnings
  from datetime import datetime
  import numpy
  from keras_tuner import backend
  from keras_tuner import utils
  from keras_tuner.api_export import keras_tuner_export
  from keras_tuner.engine import hyperparameters
  from keras_tuner.engine import objective
  from keras_tuner.engine import stateful
  from keras_tuner.engine import trial
label_desc: Use image node_id 2 for calling a global function with example usage: _maybe_infer_direction_from_objective(objective, metric_name) and returns: next