Maybe my example wasn’t broad enough. Your solution doesn’t work if the idx shapes don’t match. Say idx1 is a boolean array of shape 1000, and idx2 is of shape idx1.sum(). What would you do then?
Something like torch.where(idx1)[0][idx2] could work, but that seems very inefficient.