class_docstr: Seesaw Loss for Long-Tailed Instance Segmentation (CVPR 2021)
  arXiv: https://arxiv.org/abs/2008.10032
  
  Args:
      use_sigmoid (bool, optional): Whether the prediction uses sigmoid
           of softmax. Only False is supported.
      p (float, optional): The ``p`` in the mitigation factor.
           Defaults to 0.8.
      q (float, optional): The ``q`` in the compenstation factor.
           Defaults to 2.0.
      num_classes (int, optional): The number of classes.
           Default to 1203 for LVIS v1 dataset.
      eps (float, optional): The minimal value of divisor to smooth
           the computation of compensation factor
      reduction (str, optional): The method that reduces the loss to a
           scalar. Options are "none", "mean" and "sum".
      loss_weight (float, optional): The weight of the loss. Defaults to 1.0
      return_dict (bool, optional): Whether return the losses as a dict.
           Default to True.
class_docstr_tok: ["Seesaw","Loss","for","Long-Tailed","Instance","Segmentation","(","CVPR","2021",")","arXiv",":","https",":","\/\/arxiv.org\/abs\/2008.10032","Args",":","use_sigmoid","(","bool",",","optional",")",":","Whether","the","prediction","uses","sigmoid","of","softmax",".","Only","False","is","supported",".","p","(","float",",","optional",")",":","The","``","p","``","in","the","mitigation","factor",".","Defaults","to","0.8.","q","(","float",",","optional",")",":","The","``","q","``","in","the","compenstation","factor",".","Defaults","to","2.0.","num_classes","(","int",",","optional",")",":","The","number","of","classes",".","Default","to","1203","for","LVIS","v1","dataset",".","eps","(","float",",","optional",")",":","The","minimal","value","of","divisor","to","smooth","the","computation","of","compensation","factor","reduction","(","str",",","optional",")",":","The","method","that","reduces","the","loss","to","a","scalar",".","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","loss_weight","(","float",",","optional",")",":","The","weight","of","the","loss",".","Defaults","to","1.0","return_dict","(","bool",",","optional",")",":","Whether","return","the","losses","as","a","dict",".","Default","to","True","."]
code: def __init__(
      self,
      use_sigmoid: bool = False,
      p: float = 0.8,
      q: float = 2.0,
      num_classes: int = 1203,
      eps: float = 1e-2,
      reduction: str = "mean",
      loss_weight: float = 1.0,
      return_dict: bool = True,
  ) -> None:
      super().__init__()
      assert not use_sigmoid
      self.use_sigmoid = False
      self.p = p
      self.q = q
      self.num_classes = num_classes
      self.eps = eps
      self.reduction = reduction
      self.loss_weight = loss_weight
      self.return_dict = return_dict
  
      # 0 for pos, 1 for neg
      self.cls_criterion = seesaw_ce_loss
  
      # cumulative samples for each category
      self.register_buffer(
          "cum_samples",
          torch.zeros(self.num_classes + 1, dtype=torch.float),
      )
  
      # custom output channels of the classifier
      self.custom_cls_channels = True
      # custom activation of cls_score
      self.custom_activation = True
      # custom accuracy of the classsifier
      self.custom_accuracy = True
  
file_path: mmdetection/mmdet/models/losses/seesaw_loss.py
imports: from typing import Dict, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from mmdet.registry import MODELS
  from .accuracy import accuracy
  from .cross_entropy_loss import cross_entropy
  from .utils import weight_reduce_loss
label_desc: Use image node_id 1 to create a new SeesawLoss object from inherited base classes: nn with example: obj = SeesawLoss(use_sigmoid, p, q, num_classes, eps, reduction, loss_weight, return_dict)