class_docstr: Computer loss at one time step.
class_docstr_tok: ["Computer","loss","at","one","time","step","."]
code: def forward(self, x, target):
      # x: (*, n_classes)
      # target: (*)
      assert x.size(1) == self.size
      with T.no_grad():
          tgt_dist = T.zeros_like(x, dtype=T.float)
          tgt_dist.fill_(
              self.smoothing / (self.size - 2)
          )  # one for padding, another for label
          tgt_dist[:, self.padding_idx] = 0
          tgt_dist.scatter_(1, target.unsqueeze(1), 1 - self.smoothing)
  
          mask = T.nonzero(target == self.padding_idx)
          if mask.shape[0] > 0:
              tgt_dist.index_fill_(0, mask.squeeze(), 0)
  
      return self.criterion(x, tgt_dist)
  
imports: import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the LabelSmoothing obj's underlying member method code with example usage: obj.forward(x, target) and returns: self