class_docstr: The Mixing block.
  
  Args:
      embed_dims (int): Number of character components.
      num_heads (int): Number of heads
      mixer (str, optional): The mixer type. Defaults to 'Global'.
      window_size (Tuple[int ,int], optional): Local window size.
          Defaults to [7, 11].
      input_shape (Tuple[int, int], optional): The shape of input [H, W].
          Defaults to [8, 25].
      mlp_ratio (float, optional): The ratio of hidden features to input.
          Defaults to 4.0.
      qkv_bias (bool, optional): Whether a additive bias is required.
          Defaults to False.
      qk_scale (float, optional): A scaling factor. Defaults to None.
      drop (float, optional): cfg of Dropout. Defaults to 0..
      attn_drop (float, optional): cfg of Dropout. Defaults to 0.0.
      drop_path (float, optional): The probability of drop path.
          Defaults to 0.0.
      pernorm (bool, optional): Whether to place the MxingBlock before norm.
          Defaults to True.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
class_docstr_tok: ["The","Mixing","block",".","Args",":","embed_dims","(","int",")",":","Number","of","character","components",".","num_heads","(","int",")",":","Number","of","heads","mixer","(","str",",","optional",")",":","The","mixer","type",".","Defaults","to","'Global","'",".","window_size","(","Tuple","[","int",",","int","]",",","optional",")",":","Local","window","size",".","Defaults","to","[","7",",","11","]",".","input_shape","(","Tuple","[","int",",","int","]",",","optional",")",":","The","shape","of","input","[","H",",","W","]",".","Defaults","to","[","8",",","25","]",".","mlp_ratio","(","float",",","optional",")",":","The","ratio","of","hidden","features","to","input",".","Defaults","to","4.0.","qkv_bias","(","bool",",","optional",")",":","Whether","a","additive","bias","is","required",".","Defaults","to","False",".","qk_scale","(","float",",","optional",")",":","A","scaling","factor",".","Defaults","to","None",".","drop","(","float",",","optional",")",":","cfg","of","Dropout",".","Defaults","to","0","..","attn_drop","(","float",",","optional",")",":","cfg","of","Dropout",".","Defaults","to","0.0.","drop_path","(","float",",","optional",")",":","The","probability","of","drop","path",".","Defaults","to","0.0.","pernorm","(","bool",",","optional",")",":","Whether","to","place","the","MxingBlock","before","norm",".","Defaults","to","True",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs",".","Defaults","to","None","."]
code: def __init__(
      self,
      embed_dims: int,
      num_heads: int,
      mixer: str = "Global",
      window_size: Tuple[int, int] = [7, 11],
      input_shape: Tuple[int, int] = [8, 25],
      mlp_ratio: float = 4.0,
      qkv_bias: bool = False,
      qk_scale: float = None,
      drop: float = 0.0,
      attn_drop: float = 0.0,
      drop_path=0.0,
      prenorm: bool = True,
      init_cfg: Optional[Union[Dict, List[Dict]]] = None,
  ):
      super().__init__(init_cfg)
      self.norm1 = nn.LayerNorm(embed_dims, eps=1e-6)
      if mixer in {"Global", "Local"}:
          self.mixer = AttnMixer(
              embed_dims,
              num_heads=num_heads,
              mixer=mixer,
              input_shape=input_shape,
              local_k=window_size,
              qkv_bias=qkv_bias,
              qk_scale=qk_scale,
              attn_drop=attn_drop,
              proj_drop=drop,
          )
      elif mixer == "Conv":
          self.mixer = ConvMixer(
              embed_dims,
              num_heads=num_heads,
              input_shape=input_shape,
              local_k=window_size,
          )
      else:
          raise TypeError(
              "The mixer must be one of [Global, Local, Conv]"
          )
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.norm2 = nn.LayerNorm(embed_dims, eps=1e-6)
      mlp_hidden_dim = int(embed_dims * mlp_ratio)
      self.mlp_ratio = mlp_ratio
      self.mlp = MLP(
          in_features=embed_dims,
          hidden_features=mlp_hidden_dim,
          drop=drop,
      )
      self.prenorm = prenorm
  
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 MixingBlock object from inherited base classes: BaseModule with example: obj = MixingBlock(embed_dims, num_heads, mixer, window_size, input_shape, mlp_ratio, qkv_bias, qk_scale, drop, attn_drop, drop_path, prenorm, init_cfg)