class_docstr: An implementation of MixFFN of PVT.
  
  The differences between MixFFN & FFN:
      1. Use 1X1 Conv to replace Linear layer.
      2. Introduce 3X3 Depth-wise Conv to encode positional information.
  
  Args:
      embed_dims (int): The feature dimension. Same as
          `MultiheadAttention`.
      feedforward_channels (int): The hidden dimension of FFNs.
      act_cfg (dict, optional): The activation config for FFNs.
          Default: dict(type='GELU').
      ffn_drop (float, optional): Probability of an element to be
          zeroed in FFN. Default 0.0.
      dropout_layer (obj:`ConfigDict`): The dropout_layer used
          when adding the shortcut.
          Default: None.
      use_conv (bool): If True, add 3x3 DWConv between two Linear layers.
          Defaults: False.
      init_cfg (obj:`mmengine.ConfigDict`): The Config for initialization.
          Default: None.
class_docstr_tok: ["An","implementation","of","MixFFN","of","PVT",".","The","differences","between","MixFFN","&","FFN",":","1",".","Use","1X1","Conv","to","replace","Linear","layer",".","2",".","Introduce","3X3","Depth-wise","Conv","to","encode","positional","information",".","Args",":","embed_dims","(","int",")",":","The","feature","dimension",".","Same","as","`","MultiheadAttention","`",".","feedforward_channels","(","int",")",":","The","hidden","dimension","of","FFNs",".","act_cfg","(","dict",",","optional",")",":","The","activation","config","for","FFNs",".","Default",":","dict","(","type='GELU","'",")",".","ffn_drop","(","float",",","optional",")",":","Probability","of","an","element","to","be","zeroed","in","FFN",".","Default","0.0.","dropout_layer","(","obj",":","`","ConfigDict","`",")",":","The","dropout_layer","used","when","adding","the","shortcut",".","Default",":","None",".","use_conv","(","bool",")",":","If","True",",","add","3x3","DWConv","between","two","Linear","layers",".","Defaults",":","False",".","init_cfg","(","obj",":","`","mmengine.ConfigDict","`",")",":","The","Config","for","initialization",".","Default",":","None","."]
code: def __init__(
      self,
      embed_dims,
      feedforward_channels,
      act_cfg=dict(type="GELU"),
      ffn_drop=0.0,
      dropout_layer=None,
      use_conv=False,
      init_cfg=None,
  ):
      super(MixFFN, self).__init__(init_cfg=init_cfg)
  
      self.embed_dims = embed_dims
      self.feedforward_channels = feedforward_channels
      self.act_cfg = act_cfg
      activate = build_activation_layer(act_cfg)
  
      in_channels = embed_dims
      fc1 = Conv2d(
          in_channels=in_channels,
          out_channels=feedforward_channels,
          kernel_size=1,
          stride=1,
          bias=True,
      )
      if use_conv:
          # 3x3 depth wise conv to provide positional encode information
          dw_conv = Conv2d(
              in_channels=feedforward_channels,
              out_channels=feedforward_channels,
              kernel_size=3,
              stride=1,
              padding=(3 - 1) // 2,
              bias=True,
              groups=feedforward_channels,
          )
      fc2 = Conv2d(
          in_channels=feedforward_channels,
          out_channels=in_channels,
          kernel_size=1,
          stride=1,
          bias=True,
      )
      drop = nn.Dropout(ffn_drop)
      layers = [fc1, activate, drop, fc2, drop]
      if use_conv:
          layers.insert(1, dw_conv)
      self.layers = Sequential(*layers)
      self.dropout_layer = (
          build_dropout(dropout_layer)
          if dropout_layer
          else torch.nn.Identity()
      )
  
imports: import math
  import warnings
  from collections import OrderedDict
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d, build_activation_layer, build_norm_layer
  from mmcv.cnn.bricks.drop import build_dropout
  from mmcv.cnn.bricks.transformer import MultiheadAttention
  from mmengine.logging import MMLogger
  from mmengine.model import BaseModule, ModuleList, Sequential, constant_init, normal_init, trunc_normal_init
  from mmengine.model.weight_init import trunc_normal_
  from mmengine.runner.checkpoint import CheckpointLoader, load_state_dict
  from torch.nn.modules.utils import _pair
  from mmdet.registry import MODELS
  from ..layers import PatchEmbed, nchw_to_nlc, nlc_to_nchw
label_desc: Use image node_id 1 to create a new MixFFN object from inherited base classes: BaseModule with example: obj = MixFFN(embed_dims, feedforward_channels, act_cfg, ffn_drop, dropout_layer, use_conv, init_cfg)