class_docstr: Container for both a hyperparameter space, and current values.
  
  A `HyperParameters` instance can be pass to `HyperModel.build(hp)` as an
  argument to build a model.
  
  To prevent the users from depending on inactive hyperparameter values, only
  active hyperparameters should have values in `HyperParameters.values`.
  
  Attributes:
      space: A list of `HyperParameter` objects.
      values: A dict mapping hyperparameter names to current values.
docstr: Add and remove values if necessary.
  
  KerasTuner requires only active values to be populated. This function
  removes the inactive values and add the missing active values.
  
  Args:
      hps: HyperParameters, whose values to be ensured.
docstr_tok: ["Add","and","remove","values","if","necessary",".","KerasTuner","requires","only","active","values","to","be","populated",".","This","function","removes","the","inactive","values","and","add","the","missing","active","values",".","Args",":","hps",":","HyperParameters",",","whose","values","to","be","ensured","."]
code: def ensure_active_values(self):
      """Add and remove values if necessary.
  
      KerasTuner requires only active values to be populated. This function
      removes the inactive values and add the missing active values.
  
      Args:
          hps: HyperParameters, whose values to be ensured.
      """
      for hp in self.space:
          if self.is_active(hp):
              if hp.name not in self.values:
                  self.values[hp.name] = hp.random_sample()
          else:
              self.values.pop(hp.name, None)
  
imports: import collections
  import contextlib
  import copy
  import six
  from keras_tuner import protos
  from keras_tuner.api_export import keras_tuner_export
  from keras_tuner.engine import conditions
  from keras_tuner.engine.hyperparameters import hp_types
  from keras_tuner.engine.hyperparameters import hyperparameter
label_desc: Use image node_id 22 for calling the HyperParameters obj's underlying member method code with example usage: obj.ensure_active_values() without return types