I was reading the documentation of torch.multinomial() method in the online documentation 58.
I tried this in IPython environment.
weights = torch.Tensor([0, 10, 3, 0])
print weights   # out: [torch.FloatTensor of size 4]
torch.multinomial(weights, 5)

Of course, error occurs because 5 is larger than the size of weights and I didn’t set replacement=True. The error message is like this:
RuntimeError: cannot sample n_sample > prob_dist:size(1) samples without replacement at /home/me/pytorch/pytorch/torch/lib/TH/generic/THTensorRandom.c:94

But after this, the dimensions of weights changed.
print weights  # out: [torch.FloatTensor of size 1x4]

If I run as following without runtime exception, then the dimensions of weights do not change.
weights = torch.Tensor([0, 10, 3, 0]) 
print weights # out: [torch.FloatTensor of size 4]
torch.multinomial(weights, 4)
print weights # out: [torch.FloatTensor of size 4]