class_docstr: Implement attention decoder.
  
  Args:
      in_channels (int): Number of input channels.
      emb_dims (int): Dims of char embedding. Defaults to 512.
      attn_dims (int): Dims of attention. Both hidden states and features
          will be projected to this dims. Defaults to 512.
      hidden_size (int): Dims of hidden state for GRU. Defaults to 512.
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`. Defaults to None.
      max_seq_len (int): Maximum output sequence length :math:`T`. Defaults
          to 25.
      module_loss (dict, optional): Config to build loss. Defaults to None.
      postprocessor (dict, optional): Config to build postprocessor.
          Defaults to None.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
class_docstr_tok: ["Implement","attention","decoder",".","Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","emb_dims","(","int",")",":","Dims","of","char","embedding",".","Defaults","to","512.","attn_dims","(","int",")",":","Dims","of","attention",".","Both","hidden","states","and","features","will","be","projected","to","this","dims",".","Defaults","to","512.","hidden_size","(","int",")",":","Dims","of","hidden","state","for","GRU",".","Defaults","to","512.","dictionary","(","dict","or",":","obj",":","`","Dictionary","`",")",":","The","config","for","`","Dictionary","`","or","the","instance","of","`","Dictionary","`",".","Defaults","to","None",".","max_seq_len","(","int",")",":","Maximum","output","sequence","length",":","math",":","`","T","`",".","Defaults","to","25.","module_loss","(","dict",",","optional",")",":","Config","to","build","loss",".","Defaults","to","None",".","postprocessor","(","dict",",","optional",")",":","Config","to","build","postprocessor",".","Defaults","to","None",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs",".","Defaults","to","None","."]
code: def __init__(
      self,
      in_channels: int,
      emb_dims: int = 512,
      attn_dims: int = 512,
      hidden_size: int = 512,
      dictionary: Union[Dictionary, Dict] = None,
      max_seq_len: int = 25,
      module_loss: Dict = None,
      postprocessor: Dict = None,
      init_cfg=dict(type="Xavier", layer="Conv2d"),
  ):
      super().__init__(
          init_cfg=init_cfg,
          dictionary=dictionary,
          module_loss=module_loss,
          postprocessor=postprocessor,
          max_seq_len=max_seq_len,
      )
  
      self.start_idx = self.dictionary.start_idx
      self.num_classes = self.dictionary.num_classes
      self.in_channels = in_channels
      self.embedding_dim = emb_dims
      self.att_dims = attn_dims
      self.hidden_size = hidden_size
  
      # Projection layers
      self.proj_feat = nn.Linear(in_channels, attn_dims)
      self.proj_hidden = nn.Linear(hidden_size, attn_dims)
      self.proj_sum = nn.Linear(attn_dims, 1)
  
      # Decoder input embedding
      self.embedding = nn.Embedding(self.num_classes, self.att_dims)
  
      # GRU
      self.gru = nn.GRU(
          input_size=self.in_channels + self.embedding_dim,
          hidden_size=self.hidden_size,
          batch_first=True,
      )
  
      # Prediction layer
      self.fc = nn.Linear(hidden_size, self.dictionary.num_classes)
      self.softmax = nn.Softmax(dim=-1)
  
file_path: mmocr/mmocr/models/textrecog/decoders/aster_decoder.py
imports: from typing import Dict, Optional, Sequence, Tuple, Union
  import torch
  import torch.nn
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.registry import MODELS
  from mmocr.structures import TextRecogDataSample
  from .base import BaseDecoder
label_desc: Use image node_id 1 to create a new ASTERDecoder object from inherited base classes: BaseDecoder with example: obj = ASTERDecoder(in_channels, emb_dims, attn_dims, hidden_size, dictionary, max_seq_len, module_loss, postprocessor, init_cfg)