code: def __init__(self, config: MgpstrConfig) -> None:
      super().__init__(config)
  
      self.num_labels = config.num_labels
      self.mgp_str = MgpstrModel(config)
  
      self.char_a3_module = MgpstrA3Module(config)
      self.bpe_a3_module = MgpstrA3Module(config)
      self.wp_a3_module = MgpstrA3Module(config)
  
      self.char_head = nn.Linear(
          config.hidden_size, config.num_character_labels
      )
      self.bpe_head = nn.Linear(
          config.hidden_size, config.num_bpe_labels
      )
      self.wp_head = nn.Linear(
          config.hidden_size, config.num_wordpiece_labels
      )
  
imports: import collections.abc
  from dataclasses import dataclass
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch import nn
  from ...modeling_outputs import BaseModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import ModelOutput, add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_mgp_str import MgpstrConfig
label_desc: Use image node_id 1 to create a new MgpstrForSceneTextRecognition object from inherited base classes: MgpstrPreTrainedModel with example: obj = MgpstrForSceneTextRecognition(config)