docstr: Function to sample a new configuration
  
  This function is called inside Hyperband to query a new configuration
  
  
  Parameters:
  -----------
  budget: float
          the budget for which this configuration is scheduled
  
  returns: config
          should return a valid configuration
docstr_tok: ["Function","to","sample","a","new","configuration","This","function","is","called","inside","Hyperband","to","query","a","new","configuration","Parameters",":","--","--","--","--","--","-","budget",":","float","the","budget","for","which","this","configuration","is","scheduled","returns",":","config","should","return","a","valid","configuration"]
code: def get_config(self, budget):
      """
      Function to sample a new configuration
  
      This function is called inside Hyperband to query a new configuration
  
  
      Parameters:
      -----------
      budget: float
              the budget for which this configuration is scheduled
  
      returns: config
              should return a valid configuration
  
      """
      sample = None
      info_dict = {}
  
      # If no model is available, sample from prior
      # also mix in a fraction of random configs
      if (
          len(self.kde_models.keys()) == 0
          or np.random.rand() < self.random_fraction
      ):
          sample = self.configspace.sample_configuration()
          info_dict["model_based_pick"] = False
  
      if sample is None:
          try:
              # import pdb; pdb.set_trace()
              samples = self.kde_models[budget]["good"].sample(
                  self.num_samples
              )
              ei = self.kde_models[budget]["good"].pdf(
                  samples
              ) / self.kde_models[budget]["bad"].pdf(samples)
  
              best_idx = np.argmax(ei)
              best_vector = samples[best_idx]
  
              sample = ConfigSpace.Configuration(
                  self.configspace, vector=best_vector
              )
  
              sample = (
                  ConfigSpace.util.deactivate_inactive_hyperparameters(
                      configuration_space=self.configspace,
                      configuration=sample.get_dictionary(),
                  )
              )
              info_dict["model_based_pick"] = True
  
          except Exception as e:
              self.logger.warning(
                  ("=" * 50 + "\n") * 3
                  + "Error sampling a configuration!\n"
                  + "Models for budgets: %s" % (self.kde_models.keys())
                  + "\n here is a traceback:"
                  + traceback.format_exc()
              )
  
              for b, l in self.losses.items():
                  self.logger.debug(
                      "budget: {}\nlosses:{}".format(b, l)
                  )
  
              sample = self.configspace.sample_configuration()
              info_dict["model_based_pick"] = False
  
      return sample.get_dictionary(), info_dict
  
file_path: HpBandSter/hpbandster/optimizers/config_generators/h2bo.py
imports: import logging
  from copy import deepcopy
  import traceback
  import ConfigSpace
  import ConfigSpace.hyperparameters
  import ConfigSpace.util
  import numpy
  import scipy.stats
  from hpbandster.core.base_config_generator import base_config_generator
  from hpbandster.optimizers.kde.mvkde import MultivariateKDE
label_desc: Use image node_id 3 for calling the H2BO obj's underlying member method code with example usage: obj.get_config(budget) and returns: sample,  info_dict