class_docstr: A special decoder responsible for mixing and aligning visual feature
  and linguistic feature. `ABINet <https://arxiv.org/abs/2103.06495>`_
  
  Args:
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`. The dictionary must have an end
          token.
      vision_decoder (dict): The config for vision decoder.
      language_decoder (dict, optional): The config for language decoder.
      num_iters (int): Rounds of iterative correction. Defaults to 1.
      d_model (int): Hidden size :math:`E` of model. Defaults to 512.
      max_seq_len (int): Maximum sequence length :math:`T`. The
          sequence is usually generated from decoder. Defaults to 40.
      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 (torch.Tensor, optional): Not required. Feature map
          placeholder. Defaults to None.
      out_enc (Tensor): Raw language logitis. Shape :math:`(N, T, C)`.
          Defaults to None.
      data_samples (list[TextRecogDataSample], optional): Not required.
          DataSample placeholder. Defaults to None.
  
  Returns:
      A dict with keys ``out_enc``, ``out_decs`` and ``out_fusers``.
  
      - out_vis (dict):  Dict from ``self.vision_decoder`` with keys
        ``feature``, ``logits`` and ``attn_scores``.
      - out_langs (dict or list): Dict from ``self.vision_decoder`` with
        keys ``feature``, ``logits`` if applicable, or an empty list
        otherwise.
      - out_fusers (dict or list): Dict of fused visual and language
        features with keys ``feature``, ``logits`` if applicable, or
        an empty list otherwise.
docstr_tok: ["Args",":","feat","(","torch.Tensor",",","optional",")",":","Not","required",".","Feature","map","placeholder",".","Defaults","to","None",".","out_enc","(","Tensor",")",":","Raw","language","logitis",".","Shape",":","math",":","`","(","N",",","T",",","C",")","`",".","Defaults","to","None",".","data_samples","(","list","[","TextRecogDataSample","]",",","optional",")",":","Not","required",".","DataSample","placeholder",".","Defaults","to","None",".","Returns",":","A","dict","with","keys","``","out_enc","``",",","``","out_decs","``","and","``","out_fusers","``",".","-","out_vis","(","dict",")",":","Dict","from","``","self.vision_decoder","``","with","keys","``","feature","``",",","``","logits","``","and","``","attn_scores","``",".","-","out_langs","(","dict","or","list",")",":","Dict","from","``","self.vision_decoder","``","with","keys","``","feature","``",",","``","logits","``","if","applicable",",","or","an","empty","list","otherwise",".","-","out_fusers","(","dict","or","list",")",":","Dict","of","fused","visual","and","language","features","with","keys","``","feature","``",",","``","logits","``","if","applicable",",","or","an","empty","list","otherwise","."]
code: def forward_train(
      self,
      feat: Optional[torch.Tensor] = None,
      out_enc: torch.Tensor = None,
      data_samples: Optional[Sequence[TextRecogDataSample]] = None,
  ) -> Dict:
      """
      Args:
          feat (torch.Tensor, optional): Not required. Feature map
              placeholder. Defaults to None.
          out_enc (Tensor): Raw language logitis. Shape :math:`(N, T, C)`.
              Defaults to None.
          data_samples (list[TextRecogDataSample], optional): Not required.
              DataSample placeholder. Defaults to None.
  
      Returns:
          A dict with keys ``out_enc``, ``out_decs`` and ``out_fusers``.
  
          - out_vis (dict):  Dict from ``self.vision_decoder`` with keys
            ``feature``, ``logits`` and ``attn_scores``.
          - out_langs (dict or list): Dict from ``self.vision_decoder`` with
            keys ``feature``, ``logits`` if applicable, or an empty list
            otherwise.
          - out_fusers (dict or list): Dict of fused visual and language
            features with keys ``feature``, ``logits`` if applicable, or
            an empty list otherwise.
      """
      out_vis = self.vision_decoder(feat, out_enc, data_samples)
      out_langs = []
      out_fusers = []
      if self.language_decoder is not None:
          text_logits = out_vis["logits"]
          for _ in range(self.num_iters):
              out_dec = self.language_decoder(
                  feat, text_logits, data_samples
              )
              out_langs.append(out_dec)
              out_fuser = self.fuse(
                  out_vis["feature"], out_dec["feature"]
              )
              text_logits = out_fuser["logits"]
              out_fusers.append(out_fuser)
  
      outputs = dict(
          out_vis=out_vis, out_langs=out_langs, out_fusers=out_fusers
      )
  
      return outputs
  
file_path: mmocr/mmocr/models/textrecog/decoders/abi_fuser.py
imports: import warnings
  from typing import Dict, List, Optional, Sequence, 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 2 for calling the ABIFuser obj's underlying member method code with example usage: obj.forward_train(feat, out_enc, data_samples) and returns: outputs