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","."]
code: def __init__(
      self,
      embed_dims: int,
      num_heads: int = 8,
      mixer: str = "Global",
      input_shape: Tuple[int, int] = [8, 25],
      local_k: Tuple[int, int] = [7, 11],
      qkv_bias: bool = False,
      qk_scale: float = None,
      attn_drop: float = 0.0,
      proj_drop: float = 0.0,
      init_cfg: Optional[Union[Dict, List[Dict]]] = None,
  ):
      super().__init__(init_cfg)
      assert mixer in {
          "Global",
          "Local",
      }, "The type of mixer must belong to {'Global', 'Local'}"
      self.num_heads = num_heads
      head_dim = embed_dims // num_heads
      self.scale = qk_scale or head_dim**-0.5
      self.qkv = nn.Linear(embed_dims, embed_dims * 3, bias=qkv_bias)
      self.attn_drop = nn.Dropout(attn_drop)
      self.proj = nn.Linear(embed_dims, embed_dims)
      self.proj_drop = nn.Dropout(proj_drop)
      self.input_shape = input_shape
      if input_shape is not None:
          height, width = input_shape
          self.input_size = height * width
          self.embed_dims = embed_dims
      if mixer == "Local" and input_shape is not None:
          hk = local_k[0]
          wk = local_k[1]
          mask = torch.ones(
              [height * width, height + hk - 1, width + wk - 1],
              dtype=torch.float32,
          )
          for h in range(0, height):
              for w in range(0, width):
                  mask[h * width + w, h : h + hk, w : w + wk] = 0.0
          mask = mask[
              :, hk // 2 : height + hk // 2, wk // 2 : width + wk // 2
          ].flatten(1)
          mask[mask >= 1] = -np.inf
          self.register_buffer("mask", mask[None, None, :, :])
      self.mixer = mixer
  
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 1 to create a new AttnMixer object from inherited base classes: BaseModule with example: obj = AttnMixer(embed_dims, num_heads, mixer, input_shape, local_k, qkv_bias, qk_scale, attn_drop, proj_drop, init_cfg)