class_docstr: BERT encoder with QA head training.
class_docstr_tok: ["BERT","encoder","with","QA","head","training","."]
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      super().__init__(cfg=cfg, trainer=trainer)
      self.classifier = TokenClassifier(
          hidden_size=self.hidden_size,
          num_classes=cfg.token_classifier.num_classes,
          num_layers=cfg.token_classifier.num_layers,
          activation=cfg.token_classifier.activation,
          log_softmax=cfg.token_classifier.log_softmax,
          dropout=cfg.token_classifier.dropout,
          use_transformer_init=cfg.token_classifier.use_transformer_init,
      )
  
      self.loss = SpanningLoss()
  
imports: import json
  from typing import Optional
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from torch.cuda.amp import autocast
  from nemo.collections.common.losses import SpanningLoss
  from nemo.collections.nlp.data import SquadDataset
  from nemo.collections.nlp.data.question_answering_squad.qa_squad_processing import EVALUATION_MODE, INFERENCE_MODE, TRAINING_MODE
  from nemo.collections.nlp.models.nlp_model import NLPModel
  from nemo.collections.nlp.modules.common import TokenClassifier
  from nemo.collections.nlp.parts.utils_funcs import tensor2list
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new QAModel object from inherited base classes: NLPModel with example: obj = QAModel(cfg, trainer)