Hi,
I am  creating one hot label with this function:
def one_hot_emb(logits, label):
    lb_one_hot = logits.data.clone().zero_().scatter_(1, label.unsqueeze(1), 1)
    return lb_one_hot

It works when there is no ignore labels. When there is ignore labels such as lb_ignore=255, I hope the one hot vector at this position to be all zeros. How could I do this please?
For example, there is a label=[0,1,2] whose one hot embedding is: [[1,0,0], [0,1,0], [0,0,1]].  If the label is  label=[0,1,255], where 255 is the ignored label, the output should be: [[1,0,0], [0,1,0], [0,0,0]].
Do I have a way to do it?
The label tensor might not be 1d tensor, I can be tensor of shape N,C,H,W.