class_docstr: A model bridge for using models based on discrete parameters.
  
  Requires that all parameters have been transformed to ChoiceParameters.
class_docstr_tok: ["A","model","bridge","for","using","models","based","on","discrete","parameters",".","Requires","that","all","parameters","have","been","transformed","to","ChoiceParameters","."]
docstr: Generate new candidates according to search_space and
  optimization_config.
  
  The outcome constraints should be transformed to no longer be relative.
docstr_tok: ["Generate","new","candidates","according","to","search_space","and","optimization_config",".","The","outcome","constraints","should","be","transformed","to","no","longer","be","relative","."]
code: def _gen(
      self,
      n: int,
      search_space: SearchSpace,
      pending_observations: Dict[str, List[ObservationFeatures]],
      fixed_features: Optional[ObservationFeatures],
      model_gen_options: Optional[TConfig] = None,
      optimization_config: Optional[OptimizationConfig] = None,
  ) -> GenResults:
      """Generate new candidates according to search_space and
      optimization_config.
  
      The outcome constraints should be transformed to no longer be relative.
      """
      # Validation
      if not self.parameters:
          raise ValueError(FIT_MODEL_ERROR.format(action="_gen"))
      # Extract parameter values
      parameter_values = _get_parameter_values(
          search_space, self.parameters
      )
      # Extract objective and outcome constraints
      if len(self.outcomes) == 0 or optimization_config is None:
          objective_weights = None
          outcome_constraints = None
      else:
          validate_optimization_config(
              optimization_config, self.outcomes
          )
          objective_weights = extract_objective_weights(
              objective=optimization_config.objective,
              outcomes=self.outcomes,
          )
          outcome_constraints = extract_outcome_constraints(
              outcome_constraints=optimization_config.outcome_constraints,
              outcomes=self.outcomes,
          )
  
      # Get fixed features
      fixed_features_dict = get_fixed_features(
          fixed_features=fixed_features, param_names=self.parameters
      )
  
      # Pending observations
      if len(pending_observations) == 0:
          pending_array: Optional[List[List[TParamValueList]]] = None
      else:
          pending_array = [[] for _ in self.outcomes]
          for metric_name, po_list in pending_observations.items():
              pending_array[self.outcomes.index(metric_name)] = [
                  [po.parameters[p] for p in self.parameters]
                  for po in po_list
              ]
  
      # Generate the candidates
      X, w, gen_metadata = self.model.gen(
          n=n,
          parameter_values=parameter_values,
          objective_weights=objective_weights,
          outcome_constraints=outcome_constraints,
          fixed_features=fixed_features_dict,  # pyre-ignore
          pending_observations=pending_array,
          model_gen_options=model_gen_options,
      )
      observation_features = []
      for x in X:
          observation_features.append(
              ObservationFeatures(
                  parameters={
                      p: x[i] for i, p in enumerate(self.parameters)
                  }
              )
          )
      # TODO[drfreund, bletham]: implement best_point identification and
      # return best_point instead of None
      return GenResults(
          observation_features=observation_features,
          weights=w,
          gen_metadata=gen_metadata,
      )
  
imports: from typing import Dict, List, Optional, Set, Tuple
  from ax.core.observation import Observation, ObservationData, ObservationFeatures, separate_observations
  from ax.core.optimization_config import OptimizationConfig
  from ax.core.parameter import ChoiceParameter, FixedParameter
  from ax.core.search_space import SearchSpace
  from ax.core.types import TParamValueList
  from ax.exceptions.core import UserInputError
  from ax.modelbridge.base import GenResults, ModelBridge
  from ax.modelbridge.modelbridge_utils import array_to_observation_data, get_fixed_features
  from ax.modelbridge.torch import extract_objective_weights, extract_outcome_constraints, validate_optimization_config
  from ax.models.discrete_base import DiscreteModel
  from ax.models.types import TConfig
label_desc: Use image node_id 4 for calling the DiscreteModelBridge obj's underlying member method code with example usage: obj._gen(n, search_space, pending_observations, fixed_features, model_gen_options, optimization_config) and returns: GenResults