I wanted to know whether we could sample elements of a tensor given a probability distribution of the tensor.
In numpy we would do something like this:
a = np.array([1,2,3,4])
b = np.random.choice(a, p=np.array([0.1, 0.1, 0.1, 0.7]))

In torch I would like to have the array a and p to be of torch.tensor. The numpy function works well with CPU torch tensors translated to numpy arrays, but unfortunately, using GPUs the trick fails.