class_docstr: Implements feed-forward networks (FFNs) with identity connection.
  
  Args:
      embed_dims (int): The feature dimension. Same as
          `MultiheadAttention`. Defaults: 256.
      feedforward_channels (int): The hidden dimension of FFNs.
          Defaults: 1024.
      num_fcs (int, optional): The number of fully-connected layers in
          FFNs. Default: 2.
      act_cfg (dict, optional): The activation config for FFNs.
          Default: dict(type='ReLU')
      ffn_drop (float, optional): Probability of an element to be
          zeroed in FFN. Default 0.0.
      add_identity (bool, optional): Whether to add the
          identity connection. Default: `True`.
      dropout_layer (obj:`ConfigDict`): The dropout_layer used
          when adding the shortcut.
      init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization.
          Default: None.
class_docstr_tok: ["Implements","feed-forward","networks","(","FFNs",")","with","identity","connection",".","Args",":","embed_dims","(","int",")",":","The","feature","dimension",".","Same","as","`","MultiheadAttention","`",".","Defaults",":","256.","feedforward_channels","(","int",")",":","The","hidden","dimension","of","FFNs",".","Defaults",":","1024.","num_fcs","(","int",",","optional",")",":","The","number","of","fully-connected","layers","in","FFNs",".","Default",":","2.","act_cfg","(","dict",",","optional",")",":","The","activation","config","for","FFNs",".","Default",":","dict","(","type='ReLU","'",")","ffn_drop","(","float",",","optional",")",":","Probability","of","an","element","to","be","zeroed","in","FFN",".","Default","0.0.","add_identity","(","bool",",","optional",")",":","Whether","to","add","the","identity","connection",".","Default",":","`","True","`",".","dropout_layer","(","obj",":","`","ConfigDict","`",")",":","The","dropout_layer","used","when","adding","the","shortcut",".","init_cfg","(","obj",":","`","mmcv.ConfigDict","`",")",":","The","Config","for","initialization",".","Default",":","None","."]
docstr: Forward function for `FFN`.
  
  The function would add x to the output tensor if residue is None.
docstr_tok: ["Forward","function","for","`","FFN","`",".","The","function","would","add","x","to","the","output","tensor","if","residue","is","None","."]
code: def forward(self, x, identity=None):
      """Forward function for `FFN`.
  
      The function would add x to the output tensor if residue is None.
      """
      out = self.layers(x)
      if not self.add_identity:
          return self.dropout_layer(out)
      if identity is None:
          identity = x
      return identity + self.dropout_layer(out)
  
imports: import copy
  import warnings
  import torch
  import torch.nn
  from annotator.uniformer.mmcv import ConfigDict, deprecated_api_warning
  from annotator.uniformer.mmcv.cnn import Linear, build_activation_layer, build_norm_layer
  from annotator.uniformer.mmcv.runner.base_module import BaseModule, ModuleList, Sequential
  from annotator.uniformer.mmcv.utils import build_from_cfg
  from .drop import build_dropout
  from .registry import ATTENTION, FEEDFORWARD_NETWORK, POSITIONAL_ENCODING, TRANSFORMER_LAYER, TRANSFORMER_LAYER_SEQUENCE
label_desc: Use image node_id 2 for calling the FFN obj's underlying member method code with example usage: obj.forward(x, identity) and returns: unknown, self