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: Perform forward propagation of the head, then calculate loss and
  predictions from the features and data samples.
  
  Args:
      x (tuple[Tensor]): Features from FPN.
      batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
          the meta information of each image and corresponding
          annotations.
  
  Returns:
      tuple: the return value is a tuple contains:
  
          - losses: (dict[str, Tensor]): A dictionary of loss components.
          - predictions (list[:obj:`InstanceData`]): Detection
            results of each image after the post process.
docstr_tok: ["Perform","forward","propagation","of","the","head",",","then","calculate","loss","and","predictions","from","the","features","and","data","samples",".","Args",":","x","(","tuple","[","Tensor","]",")",":","Features","from","FPN",".","batch_data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",")",":","Each","item","contains","the","meta","information","of","each","image","and","corresponding","annotations",".","Returns",":","tuple",":","the","return","value","is","a","tuple","contains",":","-","losses",":","(","dict","[","str",",","Tensor","]",")",":","A","dictionary","of","loss","components",".","-","predictions","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Detection","results","of","each","image","after","the","post","process","."]
code: def loss_and_predict(
      self, x: Tuple[Tensor], batch_data_samples: DetSampleList
  ) -> Tuple[dict, DetSampleList]:
      """Perform forward propagation of the head, then calculate loss and
      predictions from the features and data samples.
  
      Args:
          x (tuple[Tensor]): Features from FPN.
          batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
              the meta information of each image and corresponding
              annotations.
  
      Returns:
          tuple: the return value is a tuple contains:
  
              - losses: (dict[str, Tensor]): A dictionary of loss components.
              - predictions (list[:obj:`InstanceData`]): Detection
                results of each image after the post process.
      """
      outs = self(x, batch_data_samples, mode="both")
      losses = self.module_loss(outs[:3], batch_data_samples)
      predictions = self.postprocessor(outs[3], batch_data_samples)
      return losses, predictions
  
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 6 for calling the DBHead obj's underlying member method code with example usage: obj.loss_and_predict(x, batch_data_samples) and returns: losses,  predictions