multinomial(input: Tensor, num_samples: int, replacement: bool = False, generator: _C_engine.Generator | None = None)Draw num_samples indices from the categorical distribution defined by input.
Non-differentiable — gradients of input are not propagated
through the sampling step. Pass an explicit generator for an
isolated PRNG stream; without one, draws come from Lucid's
manual_seed-controlled default Philox generator.
Parameters
inputTensorProbability weights. 1-D
(K,) for a single categorical
distribution, or 2-D (B, K) for a batch of B
distributions. Weights are renormalised internally; they need
not sum to 1.num_samplesintNumber of draws per distribution.
replacementbool= FalseWhen
True each draw is independent. When False
(default) each chosen index is removed before the next draw
within the same row.Override Lucid's default Philox generator with an isolated
stream.
Returns
TensorInteger tensor. Shape (num_samples,) for 1-D input,
(B, num_samples) for 2-D input.