Hi,
It does not work for me, my code is like this:
    def forward(self, logits, label):
        logs = self.log_softmax(logits)
        ignore = label.data==self.lb_ignore
        label[ignore] = 0
        lb_one_hot = logits.data.clone().zero_().scatter_(1, label.unsqueeze(1), 1)
        label = self.lb_pos * lb_one_hot + self.lb_neg * (1-lb_one_hot)
        ignore = ignore.nonzero()
        N, M = ignore.size()
        #  label[ignore[:,0],:,ignore[:,1],ignore[:,2]] = 0
        label[ignore.chunk(M, dim=1)] = 0

        if self.reduction == 'mean':
            loss = -torch.mean(torch.sum(logs*label, dim=1))
        elif self.reduction == 'none':
            loss = -torch.sum(logs*label, dim=1)
        return loss


Error message is:
  File "/home/zhangzy/build/miniconda/envs/py37/lib/python3.7/site-packages/torch/nn/modules/m
odule.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "label_smooth.py", line 32, in forward
    label[ignore.chunk(M, dim=1)] = 0
IndexError: index 3 is out of bounds for dimension 1 with size 3