class_docstr: Implement Adaptive 2D positional encoder for SATRN, see `SATRN.
  
  <https://arxiv.org/abs/1910.04396>`_ Modified from
  https://github.com/Media-Smart/vedastr Licensed under the Apache License,
  Version 2.0 (the "License");
  
  Args:
      d_hid (int): Dimensions of hidden layer. Defaults to 512.
      n_height (int): Max height of the 2D feature output. Defaults to 100.
      n_width (int): Max width of the 2D feature output. Defaults to 100.
      dropout (float): Dropout rate. Defaults to 0.1.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to [dict(type='Xavier', layer='Conv2d')]
docstr: Forward propagation of Locality Aware Feedforward module.
  
  Args:
      x (Tensor): Feature tensor.
  
  Returns:
      Tensor: Feature tensor after Locality Aware Feedforward.
docstr_tok: ["Forward","propagation","of","Locality","Aware","Feedforward","module",".","Args",":","x","(","Tensor",")",":","Feature","tensor",".","Returns",":","Tensor",":","Feature","tensor","after","Locality","Aware","Feedforward","."]
code: def forward(self, x: Tensor) -> Tensor:
      """Forward propagation of Locality Aware Feedforward module.
  
      Args:
          x (Tensor): Feature tensor.
  
      Returns:
          Tensor: Feature tensor after Locality Aware Feedforward.
      """
      _, _, h, w = x.size()
      avg_pool = self.pool(x)
      h_pos_encoding = (
          self.h_scale(avg_pool) * self.h_position_encoder[:, :, :h, :]
      )
      w_pos_encoding = (
          self.w_scale(avg_pool) * self.w_position_encoder[:, :, :, :w]
      )
      out = x + h_pos_encoding + w_pos_encoding
      out = self.dropout(out)
  
      return out
  
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 4 for calling the Adaptive2DPositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: out