torch.multinomial — PyTorch 2.2 documentation
Returns a tensor where each row contains num_samples indices sampled
from the multinomial (a stricter definition would be multivariate,
refer to torch.distributions.multinomial.Multinomial for more details)
probability distribution located in the corresponding row
of tensor input.
https://pytorch.org/docs/stable/generated/torch.multinomial.html