class_docstr: Decoder for ABCNet.
  
  Args:
      in_channels (int): Number of input channels.
      dropout_prob (float): Probability of dropout. Default to 0.5.
      teach_prob (float): Probability of teacher forcing. Defaults to 0.5.
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`.
      module_loss (dict, optional): Config to build module_loss. Defaults
          to None.
      postprocessor (dict, optional): Config to build postprocessor.
          Defaults to None.
      max_seq_len (int, optional): Max sequence length. Defaults to 30.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
class_docstr_tok: ["Decoder","for","ABCNet",".","Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","dropout_prob","(","float",")",":","Probability","of","dropout",".","Default","to","0.5.","teach_prob","(","float",")",":","Probability","of","teacher","forcing",".","Defaults","to","0.5.","dictionary","(","dict","or",":","obj",":","`","Dictionary","`",")",":","The","config","for","`","Dictionary","`","or","the","instance","of","`","Dictionary","`",".","module_loss","(","dict",",","optional",")",":","Config","to","build","module_loss",".","Defaults","to","None",".","postprocessor","(","dict",",","optional",")",":","Config","to","build","postprocessor",".","Defaults","to","None",".","max_seq_len","(","int",",","optional",")",":","Max","sequence","length",".","Defaults","to","30.","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs",".","Defaults","to","None","."]
code: def _attention(self, input, hidden, encoder_outputs):
      embedded = self.embedding(input)
      embedded = self.dropout(embedded)
  
      # test
      batch_size = encoder_outputs.shape[1]
  
      alpha = hidden + encoder_outputs
      alpha = alpha.view(-1, alpha.shape[-1])  # (T * n, hidden_size)
      attn_weights = self.vat(torch.tanh(alpha))  # (T * n, 1)
      attn_weights = attn_weights.view(-1, 1, batch_size).permute(
          (2, 1, 0)
      )  # (T, 1, n)  -> (n, 1, T)
      attn_weights = F.softmax(attn_weights, dim=2)
  
      attn_applied = torch.matmul(
          attn_weights, encoder_outputs.permute((1, 0, 2))
      )
  
      if embedded.dim() == 1:
          embedded = embedded.unsqueeze(0)
      output = torch.cat((embedded, attn_applied.squeeze(1)), 1)
      output = self.attn_combine(output).unsqueeze(
          0
      )  # (1, n, hidden_size)
  
      output = F.relu(output)
      output, hidden = self.gru(output, hidden)  # (1, n, hidden_size)
      output = self.out(output[0])
      return output, hidden
  
file_path: mmocr/projects/ABCNet/abcnet/model/abcnet_rec_decoder.py
imports: import random
  from typing import Dict, Optional, Sequence, Union
  import torch
  import torch.nn
  from torch.nn import functional
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.models.textrecog.decoders.base import BaseDecoder
  from mmocr.registry import MODELS
  from mmocr.structures import TextRecogDataSample
label_desc: Use image node_id 4 for calling the ABCNetRecDecoder obj's underlying member method code with example usage: obj._attention(input, hidden, encoder_outputs) and returns: output,  hidden