How to generate random tensor, excluding some elements?

Hi, I want to know how to generate random tensor, excluding some elements.
For example, I am used to using this code to generate random tensor:

rand_tensor = torch.zeros(N).random_(0, K)

where (0,K) is the range
However, sometimes I want to exclude some probability. For example, I want to generate number in (0,K), but not K/2 and K/3.
What is the most efficient way to do in this situation?

You could probably use torch.multinomial and specify the probability distribution manually.