docstr: CrossEntropyLoss.
  
  Args:
      use_sigmoid (bool, optional): Whether the prediction uses sigmoid
          of softmax. Defaults to False.
      use_mask (bool, optional): Whether to use mask cross entropy loss.
          Defaults to False.
      reduction (str, optional): . Defaults to 'mean'.
          Options are "none", "mean" and "sum".
      class_weight (list[float], optional): Weight of each class.
          Defaults to None.
      ignore_index (int | None): The label index to be ignored.
          Defaults to None.
      loss_weight (float, optional): Weight of the loss. Defaults to 1.0.
      avg_non_ignore (bool): The flag decides to whether the loss is
          only averaged over non-ignored targets. Default: False.
docstr_tok: ["CrossEntropyLoss",".","Args",":","use_sigmoid","(","bool",",","optional",")",":","Whether","the","prediction","uses","sigmoid","of","softmax",".","Defaults","to","False",".","use_mask","(","bool",",","optional",")",":","Whether","to","use","mask","cross","entropy","loss",".","Defaults","to","False",".","reduction","(","str",",","optional",")",":",".","Defaults","to","'mean","'",".","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","class_weight","(","list","[","float","]",",","optional",")",":","Weight","of","each","class",".","Defaults","to","None",".","ignore_index","(","int","|","None",")",":","The","label","index","to","be","ignored",".","Defaults","to","None",".","loss_weight","(","float",",","optional",")",":","Weight","of","the","loss",".","Defaults","to","1.0.","avg_non_ignore","(","bool",")",":","The","flag","decides","to","whether","the","loss","is","only","averaged","over","non-ignored","targets",".","Default",":","False","."]
code: def __init__(
      self,
      use_sigmoid=False,
      use_mask=False,
      reduction="mean",
      class_weight=None,
      ignore_index=None,
      loss_weight=1.0,
      avg_non_ignore=False,
  ):
      """CrossEntropyLoss.
  
      Args:
          use_sigmoid (bool, optional): Whether the prediction uses sigmoid
              of softmax. Defaults to False.
          use_mask (bool, optional): Whether to use mask cross entropy loss.
              Defaults to False.
          reduction (str, optional): . Defaults to 'mean'.
              Options are "none", "mean" and "sum".
          class_weight (list[float], optional): Weight of each class.
              Defaults to None.
          ignore_index (int | None): The label index to be ignored.
              Defaults to None.
          loss_weight (float, optional): Weight of the loss. Defaults to 1.0.
          avg_non_ignore (bool): The flag decides to whether the loss is
              only averaged over non-ignored targets. Default: False.
      """
      super(CrossEntropyLoss, self).__init__()
      assert (use_sigmoid is False) or (use_mask is False)
      self.use_sigmoid = use_sigmoid
      self.use_mask = use_mask
      self.reduction = reduction
      self.loss_weight = loss_weight
      self.class_weight = class_weight
      self.ignore_index = ignore_index
      self.avg_non_ignore = avg_non_ignore
      if (
          (ignore_index is not None)
          and not self.avg_non_ignore
          and self.reduction == "mean"
      ):
          warnings.warn(
              "Default ``avg_non_ignore`` is False, if you would like to "
              "ignore the certain label and average loss over non-ignore "
              "labels, which is the same with PyTorch official "
              "cross_entropy, set ``avg_non_ignore=True``."
          )
  
      if self.use_sigmoid:
          self.cls_criterion = binary_cross_entropy
      elif self.use_mask:
          self.cls_criterion = mask_cross_entropy
      else:
          self.cls_criterion = cross_entropy
  
imports: import warnings
  import torch
  import torch.nn
  import torch.nn.functional
  from mmdet.registry import MODELS
  from .accuracy import accuracy
  from .utils import weight_reduce_loss
label_desc: Use image node_id 1 to create a new CrossEntropyLoss object from inherited base classes: nn with example: obj = CrossEntropyLoss(use_sigmoid, use_mask, reduction, class_weight, ignore_index, loss_weight, avg_non_ignore)