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 4:

Note
When only condition is provided, this function is a shorthand for np.asarray(condition).nonzero() . Using  nonzero  1 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:
torch.where(
    torch.from_numpy(label) == 3,
    torch.from_numpy(label),
    torch.tensor([3])
)

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.