code: def convert_hyperparams_to_hparams(hyperparams, hparams_api):
      """Converts KerasTuner HyperParameters to TensorBoard HParams."""
      hparams = {}
      for hp in hyperparams.space:
          hparams_value = {}
          try:
              hparams_value = hyperparams.get(hp.name)
          except ValueError:  # pragma: no cover
              continue  # pragma: no cover
  
          hparams_domain = {}
          if isinstance(hp, hp_module.Choice):
              hparams_domain = hparams_api.Discrete(hp.values)
          elif isinstance(hp, hp_module.Int):
              if hp.step is not None and hp.step != 1:
                  # Note: `hp.max_value` is inclusive, unlike the end index
                  # of Python `range()`, which is exclusive
                  values = list(
                      range(hp.min_value, hp.max_value + 1, hp.step)
                  )
                  hparams_domain = hparams_api.Discrete(values)
              else:
                  hparams_domain = hparams_api.IntInterval(
                      hp.min_value, hp.max_value
                  )
          elif isinstance(hp, hp_module.Float):
              if hp.step is not None:
                  # Note: `hp.max_value` is inclusive, unlike the end index
                  # of Numpy's arange(), which is exclusive
                  values = np.arange(
                      hp.min_value, hp.max_value + 1e-7, step=hp.step
                  ).tolist()
                  hparams_domain = hparams_api.Discrete(values)
              else:
                  hparams_domain = hparams_api.RealInterval(
                      hp.min_value, hp.max_value
                  )
          elif isinstance(hp, hp_module.Boolean):
              hparams_domain = hparams_api.Discrete([True, False])
          elif isinstance(hp, hp_module.Fixed):
              hparams_domain = hparams_api.Discrete([hp.value])
          else:
              raise ValueError(  # pragma: no cover
                  f"`HyperParameter` type not recognized: {hp}"
              )
  
          hparams_key = hparams_api.HParam(hp.name, hparams_domain)
          hparams[hparams_key] = hparams_value
  
      return hparams
  
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 6 for calling a global function with example usage: convert_hyperparams_to_hparams(hyperparams, hparams_api) and returns: hparams