class_docstr: Masked Balanced BCE loss.
  
  Args:
      reduction (str, optional): The method to reduce the loss.
          Options are 'none', 'mean' and 'sum'. Defaults to 'none'.
      negative_ratio (float or int): Maximum ratio of negative
          samples to positive ones. Defaults to 3.
      fallback_negative_num (int): When the mask contains no
          positive samples, the number of negative samples to be sampled.
          Defaults to 0.
      eps (float): Eps to avoid zero-division error.  Defaults to
          1e-6.
class_docstr_tok: ["Masked","Balanced","BCE","loss",".","Args",":","reduction","(","str",",","optional",")",":","The","method","to","reduce","the","loss",".","Options","are","'none","'",",","'mean","'","and","'sum","'",".","Defaults","to","'none","'",".","negative_ratio","(","float","or","int",")",":","Maximum","ratio","of","negative","samples","to","positive","ones",".","Defaults","to","3.","fallback_negative_num","(","int",")",":","When","the","mask","contains","no","positive","samples",",","the","number","of","negative","samples","to","be","sampled",".","Defaults","to","0.","eps","(","float",")",":","Eps","to","avoid","zero-division","error",".","Defaults","to","1e-6","."]
code: def __init__(
      self,
      reduction: str = "none",
      negative_ratio: Union[float, int] = 3,
      fallback_negative_num: int = 0,
      eps: float = 1e-6,
  ) -> None:
      super().__init__()
      assert reduction in ["none", "mean", "sum"]
      assert isinstance(negative_ratio, (float, int))
      assert isinstance(fallback_negative_num, int)
      assert isinstance(eps, float)
      self.eps = eps
      self.negative_ratio = negative_ratio
      self.reduction = reduction
      self.fallback_negative_num = fallback_negative_num
      self.loss = nn.BCELoss(reduction=reduction)
  
file_path: mmocr/mmocr/models/common/losses/bce_loss.py
imports: from typing import Optional, Union
  import torch
  import torch.nn
  from mmocr.registry import MODELS
label_desc: Use image node_id 1 to create a new MaskedBalancedBCELoss object from inherited base classes: MaskedBalancedBCEWithLogitsLoss with example: obj = MaskedBalancedBCELoss(reduction, negative_ratio, fallback_negative_num, eps)