class_docstr: in_channels: List[int], input dim for P3, P4, P5
  out_channels: int, output dim for P2 - P7
  first_time: int, whether is the first bifpnstage
  conv_bn_act_pattern: bool, whether use conv_bn_act_pattern
  norm_cfg: (:obj:`ConfigDict` or dict, optional): Config dict for
      normalization layer.
  epsilon: float, hyperparameter in fusion features
class_docstr_tok: ["in_channels",":","List","[","int","]",",","input","dim","for","P3",",","P4",",","P5","out_channels",":","int",",","output","dim","for","P2","-","P7","first_time",":","int",",","whether","is","the","first","bifpnstage","conv_bn_act_pattern",":","bool",",","whether","use","conv_bn_act_pattern","norm_cfg",":","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","dict","for","normalization","layer",".","epsilon",":","float",",","hyperparameter","in","fusion","features"]
code: def __init__(
      self,
      in_channels: List[int],
      out_channels: int,
      first_time: bool = False,
      apply_bn_for_resampling: bool = True,
      conv_bn_act_pattern: bool = False,
      norm_cfg: OptConfigType = dict(
          type="BN", momentum=1e-2, eps=1e-3
      ),
      epsilon: float = 1e-4,
  ) -> None:
      super().__init__()
      assert isinstance(in_channels, list)
      self.in_channels = in_channels
      self.out_channels = out_channels
      self.first_time = first_time
      self.apply_bn_for_resampling = apply_bn_for_resampling
      self.conv_bn_act_pattern = conv_bn_act_pattern
      self.norm_cfg = norm_cfg
      self.epsilon = epsilon
  
      if self.first_time:
          self.p5_down_channel = DownChannelBlock(
              self.in_channels[-1],
              self.out_channels,
              apply_norm=self.apply_bn_for_resampling,
              conv_bn_act_pattern=self.conv_bn_act_pattern,
              norm_cfg=norm_cfg,
          )
          self.p4_down_channel = DownChannelBlock(
              self.in_channels[-2],
              self.out_channels,
              apply_norm=self.apply_bn_for_resampling,
              conv_bn_act_pattern=self.conv_bn_act_pattern,
              norm_cfg=norm_cfg,
          )
          self.p3_down_channel = DownChannelBlock(
              self.in_channels[-3],
              self.out_channels,
              apply_norm=self.apply_bn_for_resampling,
              conv_bn_act_pattern=self.conv_bn_act_pattern,
              norm_cfg=norm_cfg,
          )
          self.p5_to_p6 = nn.Sequential(
              DownChannelBlock(
                  self.in_channels[-1],
                  self.out_channels,
                  apply_norm=self.apply_bn_for_resampling,
                  conv_bn_act_pattern=self.conv_bn_act_pattern,
                  norm_cfg=norm_cfg,
              ),
              MaxPool2dSamePadding(3, 2),
          )
          self.p6_to_p7 = MaxPool2dSamePadding(3, 2)
          self.p4_level_connection = DownChannelBlock(
              self.in_channels[-2],
              self.out_channels,
              apply_norm=self.apply_bn_for_resampling,
              conv_bn_act_pattern=self.conv_bn_act_pattern,
              norm_cfg=norm_cfg,
          )
          self.p5_level_connection = DownChannelBlock(
              self.in_channels[-1],
              self.out_channels,
              apply_norm=self.apply_bn_for_resampling,
              conv_bn_act_pattern=self.conv_bn_act_pattern,
              norm_cfg=norm_cfg,
          )
  
      self.p6_upsample = nn.Upsample(scale_factor=2, mode="nearest")
      self.p5_upsample = nn.Upsample(scale_factor=2, mode="nearest")
      self.p4_upsample = nn.Upsample(scale_factor=2, mode="nearest")
      self.p3_upsample = nn.Upsample(scale_factor=2, mode="nearest")
  
      # bottom to up: feature map down_sample module
      self.p4_down_sample = MaxPool2dSamePadding(3, 2)
      self.p5_down_sample = MaxPool2dSamePadding(3, 2)
      self.p6_down_sample = MaxPool2dSamePadding(3, 2)
      self.p7_down_sample = MaxPool2dSamePadding(3, 2)
  
      # Fuse Conv Layers
      self.conv6_up = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv5_up = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv4_up = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv3_up = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv4_down = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv5_down = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv6_down = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      self.conv7_down = DepthWiseConvBlock(
          out_channels,
          out_channels,
          apply_norm=self.apply_bn_for_resampling,
          conv_bn_act_pattern=self.conv_bn_act_pattern,
          norm_cfg=norm_cfg,
      )
      # weights
      self.p6_w1 = nn.Parameter(
          torch.ones(2, dtype=torch.float32), requires_grad=True
      )
      self.p6_w1_relu = nn.ReLU()
      self.p5_w1 = nn.Parameter(
          torch.ones(2, dtype=torch.float32), requires_grad=True
      )
      self.p5_w1_relu = nn.ReLU()
      self.p4_w1 = nn.Parameter(
          torch.ones(2, dtype=torch.float32), requires_grad=True
      )
      self.p4_w1_relu = nn.ReLU()
      self.p3_w1 = nn.Parameter(
          torch.ones(2, dtype=torch.float32), requires_grad=True
      )
      self.p3_w1_relu = nn.ReLU()
  
      self.p4_w2 = nn.Parameter(
          torch.ones(3, dtype=torch.float32), requires_grad=True
      )
      self.p4_w2_relu = nn.ReLU()
      self.p5_w2 = nn.Parameter(
          torch.ones(3, dtype=torch.float32), requires_grad=True
      )
      self.p5_w2_relu = nn.ReLU()
      self.p6_w2 = nn.Parameter(
          torch.ones(3, dtype=torch.float32), requires_grad=True
      )
      self.p6_w2_relu = nn.ReLU()
      self.p7_w2 = nn.Parameter(
          torch.ones(2, dtype=torch.float32), requires_grad=True
      )
      self.p7_w2_relu = nn.ReLU()
  
      self.swish = Swish()
  
file_path: mmdetection/projects/EfficientDet/efficientdet/bifpn.py
imports: from typing import List
  import torch
  import torch.nn
  from mmcv.cnn.bricks import Swish
  from mmengine.model import BaseModule
  from mmdet.registry import MODELS
  from mmdet.utils import MultiConfig, OptConfigType
  from .utils import DepthWiseConvBlock, DownChannelBlock, MaxPool2dSamePadding
label_desc: Use image node_id 1 to create a new BiFPNStage object from inherited base classes: nn with example: obj = BiFPNStage(in_channels, out_channels, first_time, apply_bn_for_resampling, conv_bn_act_pattern, norm_cfg, epsilon)