class_docstr: Base decoder for text recognition, build the loss and postprocessor.
  
  Args:
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`.
      loss (dict, optional): Config to build loss. Defaults to None.
      postprocessor (dict, optional): Config to build postprocessor.
          Defaults to None.
      max_seq_len (int): Maximum sequence length. The
          sequence is usually generated from decoder. Defaults to 40.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
code: def __init__(
      self,
      dictionary: Union[Dict, Dictionary],
      module_loss: Optional[Dict] = None,
      postprocessor: Optional[Dict] = None,
      max_seq_len: int = 40,
      init_cfg: Optional[Union[Dict, List[Dict]]] = None,
  ) -> None:
      super().__init__(init_cfg=init_cfg)
      if isinstance(dictionary, dict):
          self.dictionary = TASK_UTILS.build(dictionary)
      elif isinstance(dictionary, Dictionary):
          self.dictionary = dictionary
      else:
          raise TypeError(
              "The type of dictionary should be `Dictionary` or dict, "
              f"but got {type(dictionary)}"
          )
      self.module_loss = None
      self.postprocessor = None
      self.max_seq_len = max_seq_len
  
      if module_loss is not None:
          assert isinstance(module_loss, dict)
          module_loss.update(dictionary=dictionary)
          module_loss.update(max_seq_len=max_seq_len)
          self.module_loss = MODELS.build(module_loss)
  
      if postprocessor is not None:
          assert isinstance(postprocessor, dict)
          postprocessor.update(dictionary=dictionary)
          postprocessor.update(max_seq_len=max_seq_len)
          self.postprocessor = MODELS.build(postprocessor)
  
file_path: mmocr/mmocr/models/textrecog/decoders/base.py
imports: from typing import Dict, List, Optional, Sequence, Union
  import torch
  from mmengine.model import BaseModule
  from mmocr.models.common.dictionary import Dictionary
  from mmocr.registry import MODELS, TASK_UTILS
  from mmocr.structures import TextRecogDataSample
label_desc: Use image node_id 1 to create a new BaseDecoder object from inherited base classes: BaseModule with example: obj = BaseDecoder(dictionary, module_loss, postprocessor, max_seq_len, init_cfg)