class_docstr: Implement encoder layer for SATRN, see `SATRN.
  
  <https://arxiv.org/abs/1910.04396>`_.
  
  Args:
      d_model (int): Dimension :math:`D_m` of the input from previous model.
          Defaults to 512.
      d_inner (int): Hidden dimension of feedforward layers. Defaults to 256.
      n_head (int): Number of parallel attention heads. Defaults to 8.
      d_k (int): Dimension of the key vector. Defaults to 64.
      d_v (int): Dimension of the value vector. Defaults to 64.
      dropout (float): Dropout rate. Defaults to 0.1.
      qkv_bias (bool): Whether to use bias. Defaults to False.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
docstr: Forward propagation of encoder.
  
  Args:
      x (Tensor): Feature tensor of shape :math:`(N, h*w, D_m)`.
      h (int): Height of the original feature.
      w (int): Width of the original feature.
      mask (Tensor, optional): Mask used for masked multi-head attention.
          Defaults to None.
  
  Returns:
      Tensor: A tensor of shape :math:`(N, h*w, D_m)`.
docstr_tok: ["Forward","propagation","of","encoder",".","Args",":","x","(","Tensor",")",":","Feature","tensor","of","shape",":","math",":","`","(","N",",","h","*","w",",","D_m",")","`",".","h","(","int",")",":","Height","of","the","original","feature",".","w","(","int",")",":","Width","of","the","original","feature",".","mask","(","Tensor",",","optional",")",":","Mask","used","for","masked","multi-head","attention",".","Defaults","to","None",".","Returns",":","Tensor",":","A","tensor","of","shape",":","math",":","`","(","N",",","h","*","w",",","D_m",")","`","."]
code: def forward(
      self, x: Tensor, h: int, w: int, mask: Optional[Tensor] = None
  ) -> Tensor:
      """Forward propagation of encoder.
  
      Args:
          x (Tensor): Feature tensor of shape :math:`(N, h*w, D_m)`.
          h (int): Height of the original feature.
          w (int): Width of the original feature.
          mask (Tensor, optional): Mask used for masked multi-head attention.
              Defaults to None.
  
      Returns:
          Tensor: A tensor of shape :math:`(N, h*w, D_m)`.
      """
      n, hw, c = x.size()
      residual = x
      x = self.norm1(x)
      x = residual + self.attn(x, x, x, mask)
      residual = x
      x = self.norm2(x)
      x = x.transpose(1, 2).contiguous().view(n, c, h, w)
      x = self.feed_forward(x)
      x = x.view(n, c, hw).transpose(1, 2)
      x = residual + x
      return x
  
imports: from typing import Dict, List, Optional, Union
  import numpy
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule
  from torch import Tensor
  from mmocr.models.common import MultiHeadAttention
label_desc: Use image node_id 2 for calling the SATRNEncoderLayer obj's underlying member method code with example usage: obj.forward(x, h, w, mask) and returns: x