code: def __init__(
      self,
      in_channels=[256, 512, 1024],
      out_channels=[1024, 512, 256],
      norm_type="bn",
      act="leaky",
      stage_fn="CSPStage",
      block_fn="BasicBlock",
      stage_num=1,
      block_num=3,
      drop_block=False,
      block_size=3,
      keep_prob=0.9,
      spp=False,
      data_format="NCHW",
      width_mult=1.0,
      depth_mult=1.0,
      use_alpha=False,
      trt=False,
      dim_feedforward=2048,
      dropout=0.1,
      activation="gelu",
      nhead=4,
      num_layers=4,
      attn_dropout=None,
      act_dropout=None,
      normalize_before=False,
      use_trans=False,
      eval_size=None,
  ):
      super(CustomCSPPAN, self).__init__()
      out_channels = [
          max(round(c * width_mult), 1) for c in out_channels
      ]
      block_num = max(round(block_num * depth_mult), 1)
      act = (
          get_act_fn(act, trt=trt)
          if act is None or isinstance(act, (str, dict))
          else act
      )
      self.num_blocks = len(in_channels)
      self.data_format = data_format
      self._out_channels = out_channels
  
      self.hidden_dim = in_channels[-1]
      in_channels = in_channels[::-1]
  
      self.use_trans = use_trans
      self.eval_size = eval_size
      if use_trans:
          if eval_size is not None:
              self.pos_embed = self.build_2d_sincos_position_embedding(
                  eval_size[1] // 32,
                  eval_size[0] // 32,
                  embed_dim=self.hidden_dim,
              )
          else:
              self.pos_embed = None
  
          encoder_layer = TransformerEncoderLayer(
              self.hidden_dim,
              nhead,
              dim_feedforward,
              dropout,
              activation,
              attn_dropout,
              act_dropout,
              normalize_before,
          )
          encoder_norm = (
              nn.LayerNorm(self.hidden_dim)
              if normalize_before
              else None
          )
          self.encoder = TransformerEncoder(
              encoder_layer, num_layers, encoder_norm
          )
  
      fpn_stages = []
      fpn_routes = []
      for i, (ch_in, ch_out) in enumerate(
          zip(in_channels, out_channels)
      ):
          if i > 0:
              ch_in += ch_pre // 2
  
          stage = nn.Sequential()
          for j in range(stage_num):
              stage.add_sublayer(
                  str(j),
                  eval(stage_fn)(
                      block_fn,
                      ch_in if j == 0 else ch_out,
                      ch_out,
                      block_num,
                      act=act,
                      spp=(spp and i == 0),
                      use_alpha=use_alpha,
                  ),
              )
  
          if drop_block:
              stage.add_sublayer(
                  "drop", DropBlock(block_size, keep_prob)
              )
  
          fpn_stages.append(stage)
  
          if i < self.num_blocks - 1:
              fpn_routes.append(
                  ConvBNLayer(
                      ch_in=ch_out,
                      ch_out=ch_out // 2,
                      filter_size=1,
                      stride=1,
                      padding=0,
                      act=act,
                  )
              )
  
          ch_pre = ch_out
  
      self.fpn_stages = nn.LayerList(fpn_stages)
      self.fpn_routes = nn.LayerList(fpn_routes)
  
      pan_stages = []
      pan_routes = []
      for i in reversed(range(self.num_blocks - 1)):
          pan_routes.append(
              ConvBNLayer(
                  ch_in=out_channels[i + 1],
                  ch_out=out_channels[i + 1],
                  filter_size=3,
                  stride=2,
                  padding=1,
                  act=act,
              )
          )
  
          ch_in = out_channels[i] + out_channels[i + 1]
          ch_out = out_channels[i]
          stage = nn.Sequential()
          for j in range(stage_num):
              stage.add_sublayer(
                  str(j),
                  eval(stage_fn)(
                      block_fn,
                      ch_in if j == 0 else ch_out,
                      ch_out,
                      block_num,
                      act=act,
                      spp=False,
                      use_alpha=use_alpha,
                  ),
              )
          if drop_block:
              stage.add_sublayer(
                  "drop", DropBlock(block_size, keep_prob)
              )
  
          pan_stages.append(stage)
  
      self.pan_stages = nn.LayerList(pan_stages[::-1])
      self.pan_routes = nn.LayerList(pan_routes[::-1])
  
imports: import math
  import copy
  import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register, serializable
  from ppdet.modeling.layers import DropBlock, MultiHeadAttention
  from ppdet.modeling.ops import get_act_fn
  from ..backbones.cspresnet import ConvBNLayer, BasicBlock
  from ..shape_spec import ShapeSpec
  from ..initializer import linear_init_
label_desc: Use image node_id 1 to create a new CustomCSPPAN object from inherited base classes: nn with example: obj = CustomCSPPAN(in_channels, out_channels, norm_type, act, stage_fn, block_fn, stage_num, block_num, drop_block, block_size, keep_prob, spp, data_format, width_mult, depth_mult, use_alpha, trt, dim_feedforward, dropout, activation, nhead, num_layers, attn_dropout, act_dropout, normalize_before, use_trans, eval_size)