class_docstr: L2 loss with margin.
  
  Args:
      neg_pos_ub (int, optional): The upper bound of negative to positive
          samples in hard mining. Defaults to -1.
      pos_margin (float, optional): The similarity margin for positive
          samples in hard mining. Defaults to -1.
      neg_margin (float, optional): The similarity margin for negative
          samples in hard mining. Defaults to -1.
      hard_mining (bool, optional): Whether to use hard mining. Defaults to
          False.
      reduction (str, optional): The method to reduce the loss.
          Options are "none", "mean" and "sum". Defaults to "mean".
      loss_weight (float, optional): The weight of loss. Defaults to 1.0.
class_docstr_tok: ["L2","loss","with","margin",".","Args",":","neg_pos_ub","(","int",",","optional",")",":","The","upper","bound","of","negative","to","positive","samples","in","hard","mining",".","Defaults","to","-1.","pos_margin","(","float",",","optional",")",":","The","similarity","margin","for","positive","samples","in","hard","mining",".","Defaults","to","-1.","neg_margin","(","float",",","optional",")",":","The","similarity","margin","for","negative","samples","in","hard","mining",".","Defaults","to","-1.","hard_mining","(","bool",",","optional",")",":","Whether","to","use","hard","mining",".","Defaults","to","False",".","reduction","(","str",",","optional",")",":","The","method","to","reduce","the","loss",".","Options","are","``","none","''",",","``","mean","''","and","``","sum","''",".","Defaults","to","``","mean","''",".","loss_weight","(","float",",","optional",")",":","The","weight","of","loss",".","Defaults","to","1.0","."]
code: def __init__(
      self,
      neg_pos_ub: int = -1,
      pos_margin: float = -1,
      neg_margin: float = -1,
      hard_mining: bool = False,
      reduction: str = "mean",
      loss_weight: float = 1.0,
  ):
      super(MarginL2Loss, self).__init__()
      self.neg_pos_ub = neg_pos_ub
      self.pos_margin = pos_margin
      self.neg_margin = neg_margin
      self.hard_mining = hard_mining
      self.reduction = reduction
      self.loss_weight = loss_weight
  
file_path: mmdetection/mmdet/models/losses/margin_loss.py
imports: from typing import Optional, Tuple, Union
  import numpy
  import torch
  from mmengine.model import BaseModule
  from torch import Tensor
  from mmdet.registry import MODELS
  from .mse_loss import mse_loss
label_desc: Use image node_id 1 to create a new MarginL2Loss object from inherited base classes: BaseModule with example: obj = MarginL2Loss(neg_pos_ub, pos_margin, neg_margin, hard_mining, reduction, loss_weight)