class_docstr: FPN-like fusion module in Real-time Scene Text Detection with
  Differentiable Binarization.
  
  This was partially adapted from https://github.com/MhLiao/DB and
  https://github.com/WenmuZhou/DBNet.pytorch.
  
  Args:
      in_channels (list[int]): A list of numbers of input channels.
      lateral_channels (int): Number of channels for lateral layers.
      out_channels (int): Number of output channels.
      bias_on_lateral (bool): Whether to use bias on lateral convolutional
          layers.
      bn_re_on_lateral (bool): Whether to use BatchNorm and ReLU
          on lateral convolutional layers.
      bias_on_smooth (bool): Whether to use bias on smoothing layer.
      bn_re_on_smooth (bool): Whether to use BatchNorm and ReLU on smoothing
          layer.
      asf_cfg (dict, optional): Adaptive Scale Fusion module configs. The
          attention_type can be 'ScaleChannelSpatial'.
      conv_after_concat (bool): Whether to add a convolution layer after
          the concatenation of predictions.
      init_cfg (dict or list[dict], optional): Initialization configs.
class_docstr_tok: ["FPN-like","fusion","module","in","Real-time","Scene","Text","Detection","with","Differentiable","Binarization",".","This","was","partially","adapted","from","https",":","\/\/github.com\/MhLiao\/DB","and","https",":","\/\/github.com\/WenmuZhou\/DBNet.pytorch",".","Args",":","in_channels","(","list","[","int","]",")",":","A","list","of","numbers","of","input","channels",".","lateral_channels","(","int",")",":","Number","of","channels","for","lateral","layers",".","out_channels","(","int",")",":","Number","of","output","channels",".","bias_on_lateral","(","bool",")",":","Whether","to","use","bias","on","lateral","convolutional","layers",".","bn_re_on_lateral","(","bool",")",":","Whether","to","use","BatchNorm","and","ReLU","on","lateral","convolutional","layers",".","bias_on_smooth","(","bool",")",":","Whether","to","use","bias","on","smoothing","layer",".","bn_re_on_smooth","(","bool",")",":","Whether","to","use","BatchNorm","and","ReLU","on","smoothing","layer",".","asf_cfg","(","dict",",","optional",")",":","Adaptive","Scale","Fusion","module","configs",".","The","attention_type","can","be","'ScaleChannelSpatial","'",".","conv_after_concat","(","bool",")",":","Whether","to","add","a","convolution","layer","after","the","concatenation","of","predictions",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs","."]
code: def __init__(
      self,
      in_channels: List[int],
      lateral_channels: int = 256,
      out_channels: int = 64,
      bias_on_lateral: bool = False,
      bn_re_on_lateral: bool = False,
      bias_on_smooth: bool = False,
      bn_re_on_smooth: bool = False,
      asf_cfg: Optional[Dict] = None,
      conv_after_concat: bool = False,
      init_cfg: Optional[Union[Dict, List[Dict]]] = [
          dict(type="Kaiming", layer="Conv"),
          dict(type="Constant", layer="BatchNorm", val=1.0, bias=1e-4),
      ],
  ) -> None:
      super().__init__(init_cfg=init_cfg)
      assert isinstance(in_channels, list)
      self.in_channels = in_channels
      self.lateral_channels = lateral_channels
      self.out_channels = out_channels
      self.num_ins = len(in_channels)
      self.bn_re_on_lateral = bn_re_on_lateral
      self.bn_re_on_smooth = bn_re_on_smooth
      self.asf_cfg = asf_cfg
      self.conv_after_concat = conv_after_concat
      self.lateral_convs = ModuleList()
      self.smooth_convs = ModuleList()
      self.num_outs = self.num_ins
  
      for i in range(self.num_ins):
          norm_cfg = None
          act_cfg = None
          if self.bn_re_on_lateral:
              norm_cfg = dict(type="BN")
              act_cfg = dict(type="ReLU")
          l_conv = ConvModule(
              in_channels[i],
              lateral_channels,
              1,
              bias=bias_on_lateral,
              conv_cfg=None,
              norm_cfg=norm_cfg,
              act_cfg=act_cfg,
              inplace=False,
          )
          norm_cfg = None
          act_cfg = None
          if self.bn_re_on_smooth:
              norm_cfg = dict(type="BN")
              act_cfg = dict(type="ReLU")
  
          smooth_conv = ConvModule(
              lateral_channels,
              out_channels,
              3,
              bias=bias_on_smooth,
              padding=1,
              conv_cfg=None,
              norm_cfg=norm_cfg,
              act_cfg=act_cfg,
              inplace=False,
          )
  
          self.lateral_convs.append(l_conv)
          self.smooth_convs.append(smooth_conv)
  
      if self.asf_cfg is not None:
          self.asf_conv = ConvModule(
              out_channels * self.num_outs,
              out_channels * self.num_outs,
              3,
              padding=1,
              conv_cfg=None,
              norm_cfg=None,
              act_cfg=None,
              inplace=False,
          )
          if self.asf_cfg["attention_type"] == "ScaleChannelSpatial":
              self.asf_attn = ScaleChannelSpatialAttention(
                  self.out_channels * self.num_outs,
                  (self.out_channels * self.num_outs) // 4,
                  self.num_outs,
              )
          else:
              raise NotImplementedError
  
      if self.conv_after_concat:
          norm_cfg = dict(type="BN")
          act_cfg = dict(type="ReLU")
          self.out_conv = ConvModule(
              out_channels * self.num_outs,
              out_channels * self.num_outs,
              3,
              padding=1,
              conv_cfg=None,
              norm_cfg=norm_cfg,
              act_cfg=act_cfg,
              inplace=False,
          )
  
file_path: mmocr/mmocr/models/textdet/necks/fpn_cat.py
imports: from typing import Dict, List, Optional, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule, ModuleList, Sequential
  from mmocr.registry import MODELS
label_desc: Use image node_id 1 to create a new FPNC object from inherited base classes: BaseModule with example: obj = FPNC(in_channels, lateral_channels, out_channels, bias_on_lateral, bn_re_on_lateral, bias_on_smooth, bn_re_on_smooth, asf_cfg, conv_after_concat, init_cfg)