Bug with torch.multinomial

following some of the discussions with multinomial in the past, there still seems to be some problem with its implementation in torch. 1.8.1.

The code

sample = torch.multinomial(torch.tensor([[1, 0, 0, 1]], dtype=torch.float), num_samples=3, replacement=False)
print(sample)

does not throw, nor does it for num_samples=4. However,

sample = torch.multinomial(torch.tensor([[1, 0, 0, 1]], dtype=torch.float), num_samples=5, replacement=False)
print(sample)

gives

RuntimeError: cannot sample n_sample > prob_dist.size(-1) samples without replacement

something is wrong here I guess

Thanks for raising this issue as it seems to be a valid bug.
This GitHub issue seems to already track it.