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","."]
docstr: Args:
      feat (Tensor): Feature from backbone. Unused in this decoder.
      out_enc (torch.Tensor, optional): Encoder output. Defaults to None.
      data_samples (list[TextRecogDataSample], optional): Batch of
          TextRecogDataSample, containing gt_text information. Defaults
          to None.
  
  Returns:
      Tensor: The raw logit tensor. Shape :math:`(N, T, C)` where
      :math:`C` is ``num_classes``.
docstr_tok: ["Args",":","feat","(","Tensor",")",":","Feature","from","backbone",".","Unused","in","this","decoder",".","out_enc","(","torch.Tensor",",","optional",")",":","Encoder","output",".","Defaults","to","None",".","data_samples","(","list","[","TextRecogDataSample","]",",","optional",")",":","Batch","of","TextRecogDataSample",",","containing","gt_text","information",".","Defaults","to","None",".","Returns",":","Tensor",":","The","raw","logit","tensor",".","Shape",":","math",":","`","(","N",",","T",",","C",")","`","where",":","math",":","`","C","`","is","``","num_classes","``","."]
code: def forward_train(
      self,
      feat: torch.Tensor = None,
      out_enc: Optional[torch.Tensor] = None,
      data_samples: Optional[Sequence[TextRecogDataSample]] = None,
  ) -> torch.Tensor:
      """
      Args:
          feat (Tensor): Feature from backbone. Unused in this decoder.
          out_enc (torch.Tensor, optional): Encoder output. Defaults to None.
          data_samples (list[TextRecogDataSample], optional): Batch of
              TextRecogDataSample, containing gt_text information. Defaults
              to None.
  
      Returns:
          Tensor: The raw logit tensor. Shape :math:`(N, T, C)` where
          :math:`C` is ``num_classes``.
      """
      B = out_enc.shape[0]
      state = torch.zeros(1, B, self.hidden_size).to(out_enc.device)
      padded_targets = [
          data_sample.gt_text.padded_indexes
          for data_sample in data_samples
      ]
      padded_targets = torch.stack(padded_targets, dim=0).to(
          out_enc.device
      )
      outputs = []
      for i in range(self.max_seq_len):
          prev_char = padded_targets[:, i].to(out_enc.device)
          output, state = self._attention(out_enc, state, prev_char)
          outputs.append(output)
      outputs = torch.cat([_.unsqueeze(1) for _ in outputs], 1)
      return outputs
  
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 3 for calling the ASTERDecoder obj's underlying member method code with example usage: obj.forward_train(feat, out_enc, data_samples) and returns: outputs