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 forward(self, x):
      if self.first_time:
          p3, p4, p5 = x
          # build feature map P6
          p6_in = self.p5_to_p6(p5)
          # build feature map P7
          p7_in = self.p6_to_p7(p6_in)
  
          p3_in = self.p3_down_channel(p3)
          p4_in = self.p4_down_channel(p4)
          p5_in = self.p5_down_channel(p5)
  
      else:
          p3_in, p4_in, p5_in, p6_in, p7_in = x
  
      # Weights for P6_0 and P7_0 to P6_1
      p6_w1 = self.p6_w1_relu(self.p6_w1)
      weight = p6_w1 / (torch.sum(p6_w1, dim=0) + self.epsilon)
      # Connections for P6_0 and P7_0 to P6_1 respectively
      p6_up = self.conv6_up(
          self.combine(
              weight[0] * p6_in + weight[1] * self.p6_upsample(p7_in)
          )
      )
  
      # Weights for P5_0 and P6_1 to P5_1
      p5_w1 = self.p5_w1_relu(self.p5_w1)
      weight = p5_w1 / (torch.sum(p5_w1, dim=0) + self.epsilon)
      # Connections for P5_0 and P6_1 to P5_1 respectively
      p5_up = self.conv5_up(
          self.combine(
              weight[0] * p5_in + weight[1] * self.p5_upsample(p6_up)
          )
      )
  
      # Weights for P4_0 and P5_1 to P4_1
      p4_w1 = self.p4_w1_relu(self.p4_w1)
      weight = p4_w1 / (torch.sum(p4_w1, dim=0) + self.epsilon)
      # Connections for P4_0 and P5_1 to P4_1 respectively
      p4_up = self.conv4_up(
          self.combine(
              weight[0] * p4_in + weight[1] * self.p4_upsample(p5_up)
          )
      )
  
      # Weights for P3_0 and P4_1 to P3_2
      p3_w1 = self.p3_w1_relu(self.p3_w1)
      weight = p3_w1 / (torch.sum(p3_w1, dim=0) + self.epsilon)
      # Connections for P3_0 and P4_1 to P3_2 respectively
      p3_out = self.conv3_up(
          self.combine(
              weight[0] * p3_in + weight[1] * self.p3_upsample(p4_up)
          )
      )
  
      if self.first_time:
          p4_in = self.p4_level_connection(p4)
          p5_in = self.p5_level_connection(p5)
  
      # Weights for P4_0, P4_1 and P3_2 to P4_2
      p4_w2 = self.p4_w2_relu(self.p4_w2)
      weight = p4_w2 / (torch.sum(p4_w2, dim=0) + self.epsilon)
      # Connections for P4_0, P4_1 and P3_2 to P4_2 respectively
      p4_out = self.conv4_down(
          self.combine(
              weight[0] * p4_in
              + weight[1] * p4_up
              + weight[2] * self.p4_down_sample(p3_out)
          )
      )
  
      # Weights for P5_0, P5_1 and P4_2 to P5_2
      p5_w2 = self.p5_w2_relu(self.p5_w2)
      weight = p5_w2 / (torch.sum(p5_w2, dim=0) + self.epsilon)
      # Connections for P5_0, P5_1 and P4_2 to P5_2 respectively
      p5_out = self.conv5_down(
          self.combine(
              weight[0] * p5_in
              + weight[1] * p5_up
              + weight[2] * self.p5_down_sample(p4_out)
          )
      )
  
      # Weights for P6_0, P6_1 and P5_2 to P6_2
      p6_w2 = self.p6_w2_relu(self.p6_w2)
      weight = p6_w2 / (torch.sum(p6_w2, dim=0) + self.epsilon)
      # Connections for P6_0, P6_1 and P5_2 to P6_2 respectively
      p6_out = self.conv6_down(
          self.combine(
              weight[0] * p6_in
              + weight[1] * p6_up
              + weight[2] * self.p6_down_sample(p5_out)
          )
      )
  
      # Weights for P7_0 and P6_2 to P7_2
      p7_w2 = self.p7_w2_relu(self.p7_w2)
      weight = p7_w2 / (torch.sum(p7_w2, dim=0) + self.epsilon)
      # Connections for P7_0 and P6_2 to P7_2
      p7_out = self.conv7_down(
          self.combine(
              weight[0] * p7_in
              + weight[1] * self.p7_down_sample(p6_out)
          )
      )
      return p3_out, p4_out, p5_out, p6_out, p7_out
  
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 3 for calling the BiFPNStage obj's underlying member method code with example usage: obj.forward(x) and returns: p3_out,  p4_out,  p5_out,  p6_out,  p7_out