class_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] | str, optional): Weight of each class. If in
          str format, read them from a file. Defaults to None.
      loss_weight (float, optional): Weight of the loss. Defaults to 1.0.
class_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","]","|","str",",","optional",")",":","Weight","of","each","class",".","If","in","str","format",",","read","them","from","a","file",".","Defaults","to","None",".","loss_weight","(","float",",","optional",")",":","Weight","of","the","loss",".","Defaults","to","1.0","."]
docstr: Forward function.
docstr_tok: ["Forward","function","."]
code: def forward(
      self,
      cls_score,
      label,
      weight=None,
      avg_factor=None,
      reduction_override=None,
      **kwargs,
  ):
      """Forward function."""
      assert reduction_override in (None, "none", "mean", "sum")
      reduction = (
          reduction_override if reduction_override else self.reduction
      )
      if self.class_weight is not None:
          class_weight = cls_score.new_tensor(self.class_weight)
      else:
          class_weight = None
      loss_cls = self.loss_weight * self.cls_criterion(
          cls_score,
          label,
          weight,
          class_weight=class_weight,
          reduction=reduction,
          avg_factor=avg_factor,
          **kwargs,
      )
      return loss_cls
  
file_path: lavis/lavis/common/annotator/uniformer/mmseg/models/losses/cross_entropy_loss.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from ..builder import LOSSES
  from .utils import get_class_weight, weight_reduce_loss
label_desc: Use image node_id 2 for calling the CrossEntropyLoss obj's underlying member method code with example usage: obj.forward(cls_score, label, weight, avg_factor, reduction_override) and returns: loss_cls