class_docstr: Transformer-based (duplex) tagger model for TN/ITN.
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      self.tokenizer = AutoTokenizer.from_pretrained(
          cfg.tokenizer, add_prefix_space=True
      )
      super().__init__(cfg=cfg, trainer=trainer)
      self.num_labels = len(constants.ALL_TAG_LABELS)
      self.mode = cfg.get("mode", "joint")
  
      self.model = AutoModelForTokenClassification.from_pretrained(
          cfg.transformer, num_labels=self.num_labels
      )
      self.transformer_name = cfg.transformer
      self.max_sequence_len = cfg.get(
          "max_sequence_len", self.tokenizer.model_max_length
      )
  
      # Loss Functions
      self.loss_fct = nn.CrossEntropyLoss(
          ignore_index=constants.LABEL_PAD_TOKEN_ID
      )
  
      # setup to track metrics
      self.classification_report = ClassificationReport(
          self.num_labels,
          constants.LABEL_IDS,
          mode="micro",
          dist_sync_on_step=True,
      )
  
      # Language
      self.lang = cfg.get("lang", None)
  
imports: from time import perf_counter
  from typing import Dict, List, Optional
  import torch
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from torch import nn
  from transformers import AutoModelForTokenClassification, AutoTokenizer, DataCollatorForTokenClassification
  from transformers.tokenization_utils_base import BatchEncoding
  from nemo.collections.nlp.data.text_normalization import TextNormalizationTaggerDataset, constants
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.models.duplex_text_normalization.utils import has_numbers
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types import ChannelType, LogitsType, MaskType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 5 to create a new DuplexTaggerModel object from inherited base classes: NLPModel with example: obj = DuplexTaggerModel(cfg, trainer)