class_docstr: Generator for Thompson sampling.
  
  The generator performs Thompson sampling on the data passed in via `fit`.
  Arms are given weight proportional to the probability that they are
  winners, according to Monte Carlo simulations.
class_docstr_tok: ["Generator","for","Thompson","sampling",".","The","generator","performs","Thompson","sampling","on","the","data","passed","in","via","`","fit","`",".","Arms","are","given","weight","proportional","to","the","probability","that","they","are","winners",",","according","to","Monte","Carlo","simulations","."]
code: def _produce_samples(
      self,
      num_samples: int,
      objective_weights: np.ndarray,
      outcome_constraints: Optional[Tuple[np.ndarray, np.ndarray]],
  ) -> Tuple[np.ndarray, float]:
      k = len(self.X)
      samples_per_metric = self._generate_samples_per_metric(
          num_samples=num_samples
      )
  
      any_violation = np.zeros(
          (k, num_samples), dtype=bool
      )  # (k x num_samples)
      if outcome_constraints:
          # A is (num_constraints x m)
          # b is (num_constraints x 1)
          A, b = outcome_constraints
  
          # (k x num_samples x m) dot (num_constraints x m)^T
          # = (k x num_samples x m) dot (m x num_constraints)
          # ==> (k x num_samples x num_constraints)
          constraint_values = np.dot(samples_per_metric, A.T)
          violations = constraint_values > b.T
          any_violation = np.max(
              violations, axis=2
          )  # (k x num_samples)
  
      objective_values = np.dot(
          samples_per_metric, objective_weights
      )  # (k x num_samples)
      objective_values[any_violation] = -np.Inf
      best_arm = objective_values.max(axis=0)  # (num_samples,)
      all_arms_infeasible = best_arm == -np.Inf  # (num_samples,)
      fraction_all_infeasible = all_arms_infeasible.mean()
      filtered_objective = objective_values[
          :, ~all_arms_infeasible
      ]  # (k x ?)
      return filtered_objective, fraction_all_infeasible
  
imports: import hashlib
  import json
  from typing import Dict, List, Optional, Tuple
  import numpy
  from ax.core.types import TGenMetadata, TParamValue, TParamValueList
  from ax.exceptions.constants import TS_MIN_WEIGHT_ERROR, TS_NO_FEASIBLE_ARMS_ERROR
  from ax.exceptions.model import ModelError
  from ax.models.discrete_base import DiscreteModel
  from ax.models.types import TConfig
  from ax.utils.common.docutils import copy_doc
label_desc: Use image node_id 7 for calling the ThompsonSampler obj's underlying member method code with example usage: obj._produce_samples(num_samples, objective_weights, outcome_constraints) and returns: filtered_objective,  fraction_all_infeasible