class_docstr: Implements one encoder layer in PVT.
  
  Args:
      embed_dims (int): The feature dimension.
      num_heads (int): Parallel attention heads.
      feedforward_channels (int): The hidden dimension for FFNs.
      drop_rate (float): Probability of an element to be zeroed.
          after the feed forward layer. Default: 0.0.
      attn_drop_rate (float): The drop out rate for attention layer.
          Default: 0.0.
      drop_path_rate (float): stochastic depth rate. Default: 0.0.
      qkv_bias (bool): enable bias for qkv if True.
          Default: True.
      act_cfg (dict): The activation config for FFNs.
          Default: dict(type='GELU').
      norm_cfg (dict): Config dict for normalization layer.
          Default: dict(type='LN').
      sr_ratio (int): The ratio of spatial reduction of Spatial Reduction
          Attention of PVT. Default: 1.
      use_conv_ffn (bool): If True, use Convolutional FFN to replace FFN.
          Default: False.
      init_cfg (dict, optional): Initialization config dict.
          Default: None.
class_docstr_tok: ["Implements","one","encoder","layer","in","PVT",".","Args",":","embed_dims","(","int",")",":","The","feature","dimension",".","num_heads","(","int",")",":","Parallel","attention","heads",".","feedforward_channels","(","int",")",":","The","hidden","dimension","for","FFNs",".","drop_rate","(","float",")",":","Probability","of","an","element","to","be","zeroed",".","after","the","feed","forward","layer",".","Default",":","0.0.","attn_drop_rate","(","float",")",":","The","drop","out","rate","for","attention","layer",".","Default",":","0.0.","drop_path_rate","(","float",")",":","stochastic","depth","rate",".","Default",":","0.0.","qkv_bias","(","bool",")",":","enable","bias","for","qkv","if","True",".","Default",":","True",".","act_cfg","(","dict",")",":","The","activation","config","for","FFNs",".","Default",":","dict","(","type='GELU","'",")",".","norm_cfg","(","dict",")",":","Config","dict","for","normalization","layer",".","Default",":","dict","(","type='LN","'",")",".","sr_ratio","(","int",")",":","The","ratio","of","spatial","reduction","of","Spatial","Reduction","Attention","of","PVT",".","Default",":","1.","use_conv_ffn","(","bool",")",":","If","True",",","use","Convolutional","FFN","to","replace","FFN",".","Default",":","False",".","init_cfg","(","dict",",","optional",")",":","Initialization","config","dict",".","Default",":","None","."]
code: def forward(self, x, hw_shape):
      x = self.attn(self.norm1(x), hw_shape, identity=x)
      x = self.ffn(self.norm2(x), hw_shape, identity=x)
  
      return x
  
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 2 for calling the PVTEncoderLayer obj's underlying member method code with example usage: obj.forward(x, hw_shape) and returns: x