class_docstr: The class for DBNet head.
  
  This was partially adapted from https://github.com/MhLiao/DB
  
  Args:
      in_channels (int): The number of input channels.
      with_bias (bool): Whether add bias in Conv2d layer. Defaults to False.
      module_loss (dict): Config of loss for dbnet. Defaults to
          ``dict(type='DBModuleLoss')``
      postprocessor (dict): Config of postprocessor for dbnet.
      init_cfg (dict or list[dict], optional): Initialization configs.
class_docstr_tok: ["The","class","for","DBNet","head",".","This","was","partially","adapted","from","https",":","\/\/github.com\/MhLiao\/DB","Args",":","in_channels","(","int",")",":","The","number","of","input","channels",".","with_bias","(","bool",")",":","Whether","add","bias","in","Conv2d","layer",".","Defaults","to","False",".","module_loss","(","dict",")",":","Config","of","loss","for","dbnet",".","Defaults","to","``","dict","(","type='DBModuleLoss","'",")","``","postprocessor","(","dict",")",":","Config","of","postprocessor","for","dbnet",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs","."]
docstr: Args:
      img (Tensor): Shape :math:`(N, C, H, W)`.
      data_samples (list[TextDetDataSample], optional): A list of data
          samples. Defaults to None.
      mode (str): Forward mode. It affects the return values. Options are
          "loss", "predict" and "both". Defaults to "predict".
  
          - ``loss``: Run the full network and return the prob
            logits, threshold map and binary map.
          - ``predict``: Run the binarzation part and return the prob
            map only.
          - ``both``: Run the full network and return prob logits,
            threshold map, binary map and prob map.
  
  Returns:
      Tensor or tuple(Tensor): Its type depends on ``mode``, read its
      docstring for details. Each has the shape of
      :math:`(N, 4H, 4W)`.
docstr_tok: ["Args",":","img","(","Tensor",")",":","Shape",":","math",":","`","(","N",",","C",",","H",",","W",")","`",".","data_samples","(","list","[","TextDetDataSample","]",",","optional",")",":","A","list","of","data","samples",".","Defaults","to","None",".","mode","(","str",")",":","Forward","mode",".","It","affects","the","return","values",".","Options","are","``","loss","''",",","``","predict","''","and","``","both","''",".","Defaults","to","``","predict","''",".","-","``","loss","``",":","Run","the","full","network","and","return","the","prob","logits",",","threshold","map","and","binary","map",".","-","``","predict","``",":","Run","the","binarzation","part","and","return","the","prob","map","only",".","-","``","both","``",":","Run","the","full","network","and","return","prob","logits",",","threshold","map",",","binary","map","and","prob","map",".","Returns",":","Tensor","or","tuple","(","Tensor",")",":","Its","type","depends","on","``","mode","``",",","read","its","docstring","for","details",".","Each","has","the","shape","of",":","math",":","`","(","N",",","4H",",","4W",")","`","."]
code: def forward(
      self,
      img: Tensor,
      data_samples: Optional[List[TextDetDataSample]] = None,
      mode: str = "predict",
  ) -> Tuple[Tensor, Tensor, Tensor]:
      """
      Args:
          img (Tensor): Shape :math:`(N, C, H, W)`.
          data_samples (list[TextDetDataSample], optional): A list of data
              samples. Defaults to None.
          mode (str): Forward mode. It affects the return values. Options are
              "loss", "predict" and "both". Defaults to "predict".
  
              - ``loss``: Run the full network and return the prob
                logits, threshold map and binary map.
              - ``predict``: Run the binarzation part and return the prob
                map only.
              - ``both``: Run the full network and return prob logits,
                threshold map, binary map and prob map.
  
      Returns:
          Tensor or tuple(Tensor): Its type depends on ``mode``, read its
          docstring for details. Each has the shape of
          :math:`(N, 4H, 4W)`.
      """
      prob_logits = self.binarize(img).squeeze(1)
      prob_map = self.sigmoid(prob_logits)
      if mode == "predict":
          return prob_map
      thr_map = self.threshold(img).squeeze(1)
      binary_map = self._diff_binarize(prob_map, thr_map, k=50).squeeze(
          1
      )
      if mode == "loss":
          return prob_logits, thr_map, binary_map
      return prob_logits, thr_map, binary_map, prob_map
  
file_path: mmocr/mmocr/models/textdet/heads/db_head.py
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn
  from mmengine.model import Sequential
  from torch import Tensor
  from mmocr.models.textdet.heads import BaseTextDetHead
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from mmocr.utils.typing_utils import DetSampleList
label_desc: Use image node_id 4 for calling the DBHead obj's underlying member method code with example usage: obj.forward(img, data_samples, mode) and returns: prob_logits,  thr_map,  binary_map,  prob_map, prob_map, prob_logits,  thr_map,  binary_map