class_docstr: Cross Stage Partial Layer.
  
  Args:
      in_channels (int): The input channels of the CSP layer.
      out_channels (int): The output channels of the CSP layer.
      expand_ratio (float): Ratio to adjust the number of channels of the
          hidden layer. Defaults to 0.5.
      num_blocks (int): Number of blocks. Defaults to 1.
      add_identity (bool): Whether to add identity in blocks.
          Defaults to True.
      use_cspnext_block (bool): Whether to use CSPNeXt block.
          Defaults to False.
      use_depthwise (bool): Whether to use depthwise separable convolution in
          blocks. Defaults to False.
      channel_attention (bool): Whether to add channel attention in each
          stage. Defaults to True.
      conv_cfg (dict, optional): Config dict for convolution layer.
          Defaults to None, which means using conv2d.
      norm_cfg (dict): Config dict for normalization layer.
          Defaults to dict(type='BN')
      act_cfg (dict): Config dict for activation layer.
          Defaults to dict(type='Swish')
      init_cfg (:obj:`ConfigDict` or dict or list[dict] or
          list[:obj:`ConfigDict`], optional): Initialization config dict.
          Defaults to None.
class_docstr_tok: ["Cross","Stage","Partial","Layer",".","Args",":","in_channels","(","int",")",":","The","input","channels","of","the","CSP","layer",".","out_channels","(","int",")",":","The","output","channels","of","the","CSP","layer",".","expand_ratio","(","float",")",":","Ratio","to","adjust","the","number","of","channels","of","the","hidden","layer",".","Defaults","to","0.5.","num_blocks","(","int",")",":","Number","of","blocks",".","Defaults","to","1.","add_identity","(","bool",")",":","Whether","to","add","identity","in","blocks",".","Defaults","to","True",".","use_cspnext_block","(","bool",")",":","Whether","to","use","CSPNeXt","block",".","Defaults","to","False",".","use_depthwise","(","bool",")",":","Whether","to","use","depthwise","separable","convolution","in","blocks",".","Defaults","to","False",".","channel_attention","(","bool",")",":","Whether","to","add","channel","attention","in","each","stage",".","Defaults","to","True",".","conv_cfg","(","dict",",","optional",")",":","Config","dict","for","convolution","layer",".","Defaults","to","None",",","which","means","using","conv2d",".","norm_cfg","(","dict",")",":","Config","dict","for","normalization","layer",".","Defaults","to","dict","(","type='BN","'",")","act_cfg","(","dict",")",":","Config","dict","for","activation","layer",".","Defaults","to","dict","(","type='Swish","'",")","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[","dict","]","or","list","[",":","obj",":","`","ConfigDict","`","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
docstr: Forward function.
docstr_tok: ["Forward","function","."]
code: def forward(self, x: Tensor) -> Tensor:
      """Forward function."""
      x_short = self.short_conv(x)
  
      x_main = self.main_conv(x)
      x_main = self.blocks(x_main)
  
      x_final = torch.cat((x_main, x_short), dim=1)
  
      if self.channel_attention:
          x_final = self.attention(x_final)
      return self.final_conv(x_final)
  
file_path: mmdetection/mmdet/models/layers/csp_layer.py
imports: import torch
  import torch.nn
  from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
  from mmengine.model import BaseModule
  from torch import Tensor
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
  from .se_layer import ChannelAttention
label_desc: Use image node_id 2 for calling the CSPLayer obj's underlying member method code with example usage: obj.forward(x) and returns: self