class_docstr: Converts samples from a uniform into sample (without replacement) from a
  multinomial.
class_docstr_tok: ["Converts","samples","from","a","uniform","into","sample","(","without","replacement",")","from","a","multinomial","."]
code: def perform(self, node, ins, outs):
      (pvals, unis, n_samples) = ins
      # make a copy so we do not overwrite the input
      pvals = copy.copy(pvals)
      (z,) = outs
  
      if n_samples > pvals.shape[1]:
          raise ValueError(
              "Cannot sample without replacement n samples "
              "bigger than the size of the distribution."
          )
  
      if unis.shape[0] != pvals.shape[0] * n_samples:
          raise ValueError(
              "unis.shape[0] != pvals.shape[0] * n_samples",
              unis.shape[0],
              pvals.shape[0],
              n_samples,
          )
  
      if self.odtype == "auto":
          odtype = "int64"
      else:
          odtype = self.odtype
      if z[0] is None or not np.all(
          z[0].shape == [pvals.shape[0], n_samples]
      ):
          z[0] = -1 * np.ones((pvals.shape[0], n_samples), dtype=odtype)
  
      nb_multi = pvals.shape[0]
      nb_outcomes = pvals.shape[1]
  
      # For each multinomial, loop over each possible outcome,
      # and set selected pval to 0 after being selected
      for c in range(n_samples):
          for n in range(nb_multi):
              cummul = 0
              unis_n = unis[c * nb_multi + n]
              for m in range(nb_outcomes):
                  cummul += pvals[n, m]
                  if cummul > unis_n:
                      z[0][n, c] = m
                      # set to zero and re-normalize so that it's not
                      # selected again
                      if not self.replace:
                          pvals[n, m] = 0.0
                          pvals[n] /= pvals[n].sum()
                      break
  
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import warnings
  import theano
  from theano import Op, Apply
  import theano.tensor
  from theano.scalar import as_scalar
  import copy
label_desc: Use image node_id 6 for calling the ChoiceFromUniform obj's underlying member method code with example usage: obj.perform(node, ins, outs) without return types