class_docstr: GHM Classification Loss.
  
  Details of the theorem can be viewed in the paper
  `Gradient Harmonized Single-stage Detector
  <https://arxiv.org/abs/1811.05181>`_.
  
  Args:
      bins (int): Number of the unit regions for distribution calculation.
      momentum (float): The parameter for moving average.
      use_sigmoid (bool): Can only be true for BCE based loss now.
      loss_weight (float): The weight of the total GHM-C loss.
      reduction (str): Options are "none", "mean" and "sum".
          Defaults to "mean"
class_docstr_tok: ["GHM","Classification","Loss",".","Details","of","the","theorem","can","be","viewed","in","the","paper","`","Gradient","Harmonized","Single-stage","Detector","<","https",":","\/\/arxiv.org\/abs\/1811.05181",">","`","_",".","Args",":","bins","(","int",")",":","Number","of","the","unit","regions","for","distribution","calculation",".","momentum","(","float",")",":","The","parameter","for","moving","average",".","use_sigmoid","(","bool",")",":","Can","only","be","true","for","BCE","based","loss","now",".","loss_weight","(","float",")",":","The","weight","of","the","total","GHM-C","loss",".","reduction","(","str",")",":","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","Defaults","to","``","mean","''"]
code: def __init__(
      self,
      bins=10,
      momentum=0,
      use_sigmoid=True,
      loss_weight=1.0,
      reduction="mean",
  ):
      super(GHMC, self).__init__()
      self.bins = bins
      self.momentum = momentum
      edges = torch.arange(bins + 1).float() / bins
      self.register_buffer("edges", edges)
      self.edges[-1] += 1e-6
      if momentum > 0:
          acc_sum = torch.zeros(bins)
          self.register_buffer("acc_sum", acc_sum)
      self.use_sigmoid = use_sigmoid
      if not self.use_sigmoid:
          raise NotImplementedError
      self.loss_weight = loss_weight
      self.reduction = reduction
  
file_path: mmdetection/mmdet/models/losses/ghm_loss.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from mmdet.registry import MODELS
  from .utils import weight_reduce_loss
label_desc: Use image node_id 1 to create a new GHMC object from inherited base classes: nn with example: obj = GHMC(bins, momentum, use_sigmoid, loss_weight, reduction)