code: def convert_to_metrics_dict(results, objective):
      """Convert any supported results type to a metrics dictionary."""
      # List of multiple exectuion results to be averaged.
      # Check this case first to deal each case individually to check for errors.
      if isinstance(results, list):
          return average_metrics_dicts(
              [
                  convert_to_metrics_dict(elem, objective)
                  for elem in results
              ]
          )
  
      # Single value.
      if isinstance(results, (int, float, np.floating)):
          return {objective.name: float(results)}
  
      # A dictionary.
      if isinstance(results, dict):
          return results
  
      # A History.
      if isinstance(results, keras.callbacks.History):
          best_value, _ = _get_best_value_and_best_epoch_from_history(
              results, objective
          )
          return best_value
  
imports: import collections
  import statistics
  import numpy
  from keras_tuner import backend
  from keras_tuner import errors
  from keras_tuner.backend import config
  from keras_tuner.backend import keras
  from keras_tuner.engine import hyperparameters
  from keras_tuner.engine import objective
label_desc: Use image node_id 3 for calling a global function with example usage: convert_to_metrics_dict(results, objective) and returns: average_metrics_dicts, dict, results, best_value