Note that you are basically using (label==3).nonzero() in your numpy code, since you only provide the condition without x and y. From the docs:

Note
When only condition is provided, this function is a shorthand for np.asarray(condition).nonzero() . Using nonzero directly should be preferred, as it behaves correctly for subclasses. The rest of this documentation covers only the case where all three arguments are provided.

That being said, let’s check the PyTorch code.
Your C++ code should be the equivalent to this Python code:

If the condition is True, the values from the first tensor will be drawn, else from the second one.
Since you are comparing the tensor to 3, all True conditions will draw exactly the 3 from label. For all False return values in the condition, you will draw the corresponding value from a tensor full of 3s, which is why your output will contain all 3s.