class_docstr: This combines the Softmax Cross-Entropy Loss (nn.CrossEntropyLoss) and the large-margin inducing
  regularization proposed in
     T. Kobayashi, "Large-Margin In Softmax Cross-Entropy Loss." In BMVC2019.
  
  This loss function inherits the parameters from nn.CrossEntropyLoss except for `reg_lambda` and `deg_logit`.
  Args:
       reg_lambda (float, optional): a regularization parameter. (default: 0.3)
       deg_logit (bool, optional): underestimate (degrade) the target logit by -1 or not. (default: False)
                                   If True, it realizes the method that incorporates the modified loss into ours
                                   as described in the above paper (Table 4).
code: def forward(self, input, target):
      N = input.size(0)  # number of samples
      C = input.size(1)  # number of classes
      Mask = torch.zeros_like(input, requires_grad=False)
      Mask[range(N), target] = 1
  
      if self.deg_logit is not None:
          input = input - self.deg_logit * Mask
  
      loss = F.cross_entropy(
          input,
          target,
          weight=self.weight,
          ignore_index=self.ignore_index,
          reduction=self.reduction,
      )
  
      X = input - 1.0e6 * Mask  # [N x C], excluding the target class
      reg = 0.5 * (
          (F.softmax(X, dim=1) - 1.0 / (C - 1))
          * F.log_softmax(X, dim=1)
          * (1.0 - Mask)
      ).sum(dim=1)
      if self.reduction == "sum":
          reg = reg.sum()
      elif self.reduction == "mean":
          reg = reg.mean()
      elif self.reduction == "none":
          reg = reg
  
      return loss + self.reg_lambda * reg
  
file_path: stanza/stanza/models/common/large_margin_loss.py
imports: import math
  import torch
  import torch.nn
  import torch.nn.init
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the LargeMarginInSoftmaxLoss obj's underlying member method code with example usage: obj.forward(input, target) and returns: unknown