code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      # must assign tokenizers before init
      if cfg.language_model.pretrained_model_name:
          if (
              cfg.language_model.pretrained_encoder_model_name
              or cfg.language_model.pretrained_decoder_model_name
          ):
              raise ValueError(
                  "Must have either pretrained_model_name or both pretrained_encoder_model name and "
                  "pretrained_decoder_model_name."
              )
          # setup tokenizer
          self.encoder_tokenizer = self.setup_tokenizer(
              cfg.encoder_tokenizer
          )
          self.encoder_add_special_tokens = (
              cfg.encoder_tokenizer.add_special_tokens
          )
  
          # set decoder to encoder
          self.decoder_tokenizer = self.encoder_tokenizer
          self.decoder_add_special_tokens = (
              self.encoder_add_special_tokens
          )
      else:
          if not (
              cfg.language_model.pretrained_encoder_model_name
              and cfg.language_model.pretrained_decoder_model_name
          ):
              raise ValueError(
                  "Both encoder and decoder must be specified"
              )
  
          # setup tokenizers
          self.encoder_tokenizer = self.setup_tokenizer(
              cfg.encoder_tokenizer
          )
          self.encoder_add_special_tokens = (
              cfg.encoder_tokenizer.add_special_tokens
          )
  
          self.decoder_tokenizer = self.setup_tokenizer(
              cfg.decoder_tokenizer
          )
          self.decoder_add_special_tokens = (
              cfg.decoder_tokenizer.add_special_tokens
          )
  
      if not self.encoder_tokenizer:
          raise TypeError("encoder_tokenizer failed to initialize")
      if not self.decoder_tokenizer:
          raise TypeError("decoder_tokenizer failed to initialize")
  
      # init superclass
      super().__init__(cfg=cfg, trainer=trainer)
  
      # must assign modules after init
      if cfg.language_model.pretrained_model_name:
          # Setup end-to-end model
          if "bart" in cfg.language_model.pretrained_model_name:
              self.model = BartForConditionalGeneration.from_pretrained(
                  cfg.language_model.pretrained_model_name
              )
          else:
              self.model = AutoModel.from_pretrained(
                  cfg.language_model.pretrained_model_name
              )
      else:
          if not (
              cfg.language_model.pretrained_encoder_model_name
              and cfg.language_model.pretrained_decoder_model_name
          ):
              raise ValueError(
                  "Both encoder and decoder must be specified"
              )
  
          # Setup encoder/decoder model
          self.model = EncoderDecoderModel.from_encoder_decoder_pretrained(
              encoder=cfg.language_model.pretrained_encoder_model_name,
              decoder=cfg.language_model.pretrained_decoder_model_name,
          )
  
      self.validation_perplexity = Perplexity()
  
      self.setup_optimization(cfg.optim)
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from transformers import AutoModel, BartForConditionalGeneration, EncoderDecoderModel
  from nemo.collections.common.metrics import Perplexity
  from nemo.collections.nlp.data.text2sparql import Text2SparqlDataset
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.core.classes.common import typecheck
  from nemo.core.classes.modelPT import ModelPT
  from nemo.core.neural_types import ChannelType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 2 to create a new Text2SparqlModel object from inherited base classes: ModelPT with example: obj = Text2SparqlModel(cfg, trainer)