How to index tensor by using all but given indices in pytorch?
Suppose I have a Tensor a
&gt;&gt;&gt; a
tensor([[2, 8],
        [3, 0],
        [4, 2],
        [2, 2],
        [6, 8]])

I also have a tensor idx consisting of indices that I don't want to select
&gt;&gt;&gt; idx
tensor([0, 3, 4])

How should I go ahead and select all rows except the ones whose indices are present in the tensor idx?
For the above tensors a and idx, after selection, I should get the output Tensor b as
&gt;&gt;&gt; b
tensor([[3, 0],
        [4, 2]])


a[[i for i in range(len(a)) if i not in idx]]
