class_docstr: One of mixer of {'Global', 'Local'}. Defaults to Global Mixer.
  
  Args:
      embed_dims (int): Number of character components.
      num_heads (int, optional): Number of heads. Defaults to 8.
      mixer (str, optional): The mixer type, choices are 'Global' and
          'Local'. Defaults to 'Global'.
      input_shape (Tuple[int, int], optional): The shape of input [H, W].
          Defaults to [8, 25].
      local_k (Tuple[int, int], optional): Window size. Defaults to [7, 11].
      qkv_bias (bool, optional): Whether a additive bias is required.
          Defaults to False.
      qk_scale (float, optional): A scaling factor. Defaults to None.
      attn_drop (float, optional): Attn dropout probability. Defaults to 0.0.
      proj_drop (float, optional): Proj dropout layer. Defaults to 0.0.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
class_docstr_tok: ["One","of","mixer","of","{","'Global","'",",","'Local","'","}",".","Defaults","to","Global","Mixer",".","Args",":","embed_dims","(","int",")",":","Number","of","character","components",".","num_heads","(","int",",","optional",")",":","Number","of","heads",".","Defaults","to","8.","mixer","(","str",",","optional",")",":","The","mixer","type",",","choices","are","'Global","'","and","'Local","'",".","Defaults","to","'Global","'",".","input_shape","(","Tuple","[","int",",","int","]",",","optional",")",":","The","shape","of","input","[","H",",","W","]",".","Defaults","to","[","8",",","25","]",".","local_k","(","Tuple","[","int",",","int","]",",","optional",")",":","Window","size",".","Defaults","to","[","7",",","11","]",".","qkv_bias","(","bool",",","optional",")",":","Whether","a","additive","bias","is","required",".","Defaults","to","False",".","qk_scale","(","float",",","optional",")",":","A","scaling","factor",".","Defaults","to","None",".","attn_drop","(","float",",","optional",")",":","Attn","dropout","probability",".","Defaults","to","0.0.","proj_drop","(","float",",","optional",")",":","Proj","dropout","layer",".","Defaults","to","0.0.","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs",".","Defaults","to","None","."]
docstr: Forward function.
  
  Args:
      x (torch.Tensor): A Tensor of shape :math:`(N, H, W, C)`.
  
  Returns:
      torch.Tensor: A Tensor of shape :math:`(N, H, W, C)`.
docstr_tok: ["Forward","function",".","Args",":","x","(","torch.Tensor",")",":","A","Tensor","of","shape",":","math",":","`","(","N",",","H",",","W",",","C",")","`",".","Returns",":","torch.Tensor",":","A","Tensor","of","shape",":","math",":","`","(","N",",","H",",","W",",","C",")","`","."]
code: def forward(self, x: torch.Tensor) -> torch.Tensor:
      """Forward function.
  
      Args:
          x (torch.Tensor): A Tensor of shape :math:`(N, H, W, C)`.
  
      Returns:
          torch.Tensor: A Tensor of shape :math:`(N, H, W, C)`.
      """
      if self.input_shape is not None:
          input_size, embed_dims = self.input_size, self.embed_dims
      else:
          _, input_size, embed_dims = x.shape
      qkv = (
          self.qkv(x)
          .reshape(
              (
                  -1,
                  input_size,
                  3,
                  self.num_heads,
                  embed_dims // self.num_heads,
              )
          )
          .permute((2, 0, 3, 1, 4))
      )
      q, k, v = qkv[0] * self.scale, qkv[1], qkv[2]
      attn = q.matmul(k.permute(0, 1, 3, 2))
      if self.mixer == "Local":
          attn += self.mask
      attn = F.softmax(attn, dim=-1)
      attn = self.attn_drop(attn)
  
      x = (
          attn.matmul(v)
          .permute(0, 2, 1, 3)
          .reshape(-1, input_size, embed_dims)
      )
      x = self.proj(x)
      x = self.proj_drop(x)
      return x
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule
  from mmcv.cnn.bricks import DropPath
  from mmengine.model import BaseModule
  from mmengine.model.weight_init import trunc_normal_init
  from mmocr.registry import MODELS
  from mmocr.structures import TextRecogDataSample
label_desc: Use image node_id 2 for calling the AttnMixer obj's underlying member method code with example usage: obj.forward(x) and returns: x