WeightedRandomSampler will use torch.multinomial internally as shown here 75.
The passed weights will determine the weight to sample each index.
E.g. you can see that the returned indices will approximate the weights:
sampler = WeightedRandomSampler([10,5,10,5,10],1000, replacement=True)
indices = []
for idx in sampler:
    indices.append(idx)

print(torch.tensor(indices).unique(return_counts=True))
> (tensor([0, 1, 2, 3, 4]), tensor([280, 124, 230, 137, 229]))