class_docstr: Create a categorical distribution object.
  
  Parameters
  ----------
  num_events : Int
      Number of events.
  prob : Tensor
      Probabilities of each event.
  logit : Tensor
      The log-odds of each event
class_docstr_tok: ["Create","a","categorical","distribution","object",".","Parameters","--","--","--","--","--","num_events",":","Int","Number","of","events",".","prob",":","Tensor","Probabilities","of","each","event",".","logit",":","Tensor","The","log-odds","of","each","event"]
docstr: Sample from categorical distribution.
  Given logit/prob of size `(batch_size, num_events)`,
  `batch_size` samples will be drawn.
  If `size` is given, `np.broadcast(size, batch_size)` samples will be drawn.
  
  Parameters
  ----------
  size : int or tuple of ints
  
  Returns
  -------
  out : Tensor
      Samples from the categorical distribution.
docstr_tok: ["Sample","from","categorical","distribution",".","Given","logit\/prob","of","size","`","(","batch_size",",","num_events",")","`",",","`","batch_size","`","samples","will","be","drawn",".","If","`","size","`","is","given",",","`","np.broadcast","(","size",",","batch_size",")","`","samples","will","be","drawn",".","Parameters","--","--","--","--","--","size",":","int","or","tuple","of","ints","Returns","--","--","--","-","out",":","Tensor","Samples","from","the","categorical","distribution","."]
code: def sample(self, size=None):
      """Sample from categorical distribution.
      Given logit/prob of size `(batch_size, num_events)`,
      `batch_size` samples will be drawn.
      If `size` is given, `np.broadcast(size, batch_size)` samples will be drawn.
  
      Parameters
      ----------
      size : int or tuple of ints
  
      Returns
      -------
      out : Tensor
          Samples from the categorical distribution.
      """
      if size is None:
          size = ()
          logit = self.logit
      else:
          if isinstance(size, int):
              logit = np.broadcast_to(self.logit, (size,) + (-2,))
          else:
              logit = np.broadcast_to(self.logit, size + (-2,))
      gumbel_samples = np.random.gumbel(logit)
      return np.argmax(gumbel_samples, axis=-1)
  
file_path: mxnet/python/mxnet/gluon/probability/distributions/categorical.py
imports: from .distribution import Distribution
  from .utils import prob2logit, logit2prob, cached_property, sample_n_shape_converter
  from .constraint import Simplex, Real, IntegerInterval
  from ....None import np, npx
label_desc: Use image node_id 6 for calling the Categorical obj's underlying member method code with example usage: obj.sample(size) and returns: np