class_docstr: Class for fitting Gaussian processes. 
class_docstr_tok: ["Class","for","fitting","Gaussian","processes","."]
docstr: Samples continous and discrete hyper-parameters for post_sampling. 
docstr_tok: ["Samples","continous","and","discrete","hyper-parameters","for","post_sampling","."]
code: def _sample_cts_dscr_hps_for_post_sampling(self, num_samples):
      """Samples continous and discrete hyper-parameters for post_sampling."""
  
      # pylint: disable=too-many-branches
      # pylint: disable=too-many-locals
      def _logp(x):
          """Computes log probability of observations at x."""
          # sum of log probability priors
          if self.parameter == "additive_grp":
              if x < 0:
                  return -np.inf
              permut = list(
                  np.random.RandomState(seed=x[0]).permutation(
                      self.add_dim
                  )
              )
              groupings = [
                  permut[i : i + self.group_size]
                  for i in range(0, self.add_dim, self.group_size)
              ]
              self.other_gp_params = Namespace(
                  add_gp_groupings=groupings
              )
          elif (
              type(self.hp_priors[self.curr_hp]).__name__
              == "Categorical"
          ):
              self.hps[self.curr_hp] = self.hp_priors[
                  self.curr_hp
              ].get_category(x.item())
          else:
              self.hps[self.curr_hp] = x
  
          lp = 0
          for i, prior in enumerate(self.hp_priors):
              if type(self.hp_priors[i]).__name__ == "Categorical":
                  lp += prior.logp(
                      self.hp_priors[i].get_id(self.hps[i])
                  )
              else:
                  lp += prior.logp(self.hps[i])
          if not np.isfinite(lp):
              return lp
  
          lp += self._tuning_objective_post_sampling(
              self.hps[0 : len(self.cts_hp_bounds)],
              self.hps[len(self.cts_hp_bounds) : self.num_hps],
              self.other_gp_params,
          )
          return lp
  
      def _pdf(x):
          """Computes probability of observations at x."""
          val = _logp(x)
          if not np.isfinite(val):
              return val
          return np.exp(val)
  
      def _grad_logp(x):
          """Computes gradient of log probability of observations at x."""
          if not np.isfinite(self.hp_priors[self.curr_hp].logp(x)):
              return 0
          self.hps[self.curr_hp] = x
          lp = self.hp_priors[self.curr_hp].grad_logp(
              self.hps[self.curr_hp]
          )
          lp += self._tuning_objective_post_sampling(
              self.hps[0 : len(self.cts_hp_bounds)],
              self.hps[len(self.cts_hp_bounds) : self.num_hps],
              self.other_gp_params,
              self.parameter,
              self.param_num,
              True,
          )
          return lp
  
      offset = self.options.post_hp_tune_offset
      _model = Model(_pdf, _logp, _grad_logp)
      self.hps = np.ones((self.num_hps,))
      best_cts_hps = np.zeros([num_samples, len(self.cts_hp_bounds)])
      best_dscr_hps = np.zeros([num_samples, len(self.dscr_hp_vals)])
      best_other_gp_params = [None] * num_samples
      total_samples = (num_samples - 1) * offset + 1
      cts_hps = np.zeros([total_samples, len(self.cts_hp_bounds)])
      dscr_hps = np.zeros([total_samples, len(self.dscr_hp_vals)])
      _other_gp_params = [None] * total_samples
      self.param_num = -1
  
      # burn value
      if self.options.post_hp_tune_burn == -1:
          burn = int(np.sqrt(self.num_hps) * 100)
          np.clip(burn, 100, 2000)
      else:
          burn = self.options.post_hp_tune_burn
  
      # Initializing hyper parameters
      for i in range(len(self.cts_hp_bounds)):
          self.hps[i] = self.hp_priors[i].get_mean()
      for i in range(len(self.cts_hp_bounds), self.num_hps):
          self.hps[i] = self.hp_priors[i].draw_samples("random", 1)
          if type(self.hp_priors[i]).__name__ == "Categorical":
              self.hps[i] = self.hp_priors[i].get_category(
                  int(self.hps[i])
              )
  
      # Grouping intitialization for additive gp
      if vars(self.options).get("use_additive_gp", False) or vars(
          self.options
      ).get("domain_use_additive_gp", False):
          if vars(self.options).get("domain_use_additive_gp", False):
              self.add_dim = self.domain_dim
              add_max_group_size = self.domain_add_max_group_size
          else:
              self.add_dim = self.dim
              add_max_group_size = self.add_max_group_size
          permut = list(np.random.permutation(self.add_dim))
          groupings = [
              permut[i : i + int(self.hps[-1])]
              for i in range(0, self.add_dim, int(self.hps[-1]))
          ]
          self.other_gp_params = Namespace(add_gp_groupings=groupings)
      else:
          self.other_gp_params = Namespace(add_gp_groupings=None)
  
      # Randomly selcting a parameter and sampling it using tuning objective
      order = list(range(self.num_hps))
      np.random.shuffle(order)
      for i in order:
          self.curr_hp = i
          self.parameter = self.param_order[i][0]
          if self.parameter == "dim_bandwidths":
              self.param_num = self.param_num + 1
          dscr_i = i - len(self.cts_hp_bounds)
          if self.param_order[i][-1] == "cts":
              cts_hps[:, i] = np.squeeze(
                  self.hp_sampler_cts(
                      _model, self.hps[i], total_samples, burn
                  ),
                  axis=1,
              )
              self.hps[i] = cts_hps[0, i]
          elif self.parameter != "additive_grp":
              if type(self.hp_priors[i]).__name__ == "Categorical":
                  init_sample = self.hp_priors[i].get_id(self.hps[i])
                  dscr_hp = np.squeeze(
                      self.hp_sampler_dscr(
                          _model, init_sample, total_samples
                      ),
                      axis=1,
                  )
                  for j, val in enumerate(dscr_hp):
                      dscr_hps[j, dscr_i] = self.hp_priors[
                          i
                      ].get_category(int(val))
              else:
                  dscr_hps[:, dscr_i] = np.squeeze(
                      self.hp_sampler_dscr(
                          _model, self.hps[i], total_samples
                      ),
                      axis=1,
                  )
              self.hps[i] = dscr_hps[0, dscr_i]
          else:
              dscr_hps[:, dscr_i] = np.random.randint(
                  1, add_max_group_size + 1, total_samples
              )
              seed = int(np.random.randint(self.add_dim))
              for j in range(total_samples):
                  self.group_size = int(dscr_hps[j, dscr_i])
                  seed = int(
                      np.squeeze(
                          self.hp_sampler_dscr(_model, seed, 1), axis=1
                      )
                  )
                  permut = list(
                      np.random.RandomState(seed=seed).permutation(
                          self.add_dim
                      )
                  )
                  groupings = [
                      permut[k : k + self.group_size]
                      for k in range(0, self.add_dim, self.group_size)
                  ]
                  _other_gp_params[j] = Namespace(
                      add_gp_groupings=groupings
                  )
              self.other_gp_params = _other_gp_params[0]
  
      for i in range(num_samples):
          best_cts_hps[i, :] = cts_hps[i * offset, :]
          best_dscr_hps[i, :] = dscr_hps[i * offset, :]
          best_other_gp_params[i] = _other_gp_params[i * offset]
  
      return best_cts_hps, best_dscr_hps, best_other_gp_params
  
imports: from __future__ import division
  from argparse import Namespace
  from itertools import product
  import sys
  import numpy
  from ..distributions.model import Model
  from ..distributions import continuous
  from ..distributions import discrete
  from ..utils.general_utils import stable_cholesky, draw_gaussian_samples, project_symmetric_to_psd_cone, solve_lower_triangular, solve_upper_triangular
  from ..utils.oper_utils import direct_ft_maximise, pdoo_maximise, random_maximise, random_sample_cts_dscr
  from ..utils.option_handler import get_option_specs, load_options
  from ..utils.reporters import get_reporter
label_desc: Use image node_id 16 for calling the GPFitter obj's underlying member method code with example usage: obj._sample_cts_dscr_hps_for_post_sampling(num_samples) and returns: best_cts_hps,  best_dscr_hps,  best_other_gp_params, lp, np, lp, lp, val, int, unknown