class_docstr: TextClassificationModel to be trained on two- or three-class textual entailment data, to be used for zero shot intent recognition.
class_docstr_tok: ["TextClassificationModel","to","be","trained","on","two-","or","three-class","textual","entailment","data",",","to","be","used","for","zero","shot","intent","recognition","."]
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      self.cfg = cfg
      super().__init__(cfg=cfg, trainer=trainer)
  
      if self.cfg.library == "megatron":
          # zero shot intent classification loading
          # cannot directly load as .nemo uses the pre-refactor model
          # therefore transfer its attributes over
          if self.cfg.original_nemo_checkpoint is not None:
              original_model = DialogueZeroShotIntentModel.restore_from(
                  self.cfg.original_nemo_checkpoint
              )
              self.classifier = original_model.classifier
              self.bert_model = original_model.bert_model
              self.loss = original_model.loss
              self.classification_report = (
                  original_model.classification_report
              )
      elif self.cfg.library == "huggingface":
          self.nli_model = (
              AutoModelForSequenceClassification.from_pretrained(
                  "facebook/bart-large-mnli"
              )
          )
          self.bert_model = self.nli_model.model
          self.classifier = self.nli_model.classification_head
          original_model = DialogueZeroShotIntentModel.restore_from(
              self.cfg.original_nemo_checkpoint
          )
          self.loss = original_model.loss
          self.classification_report = (
              original_model.classification_report
          )
          self.tokenizer = AutoTokenizer.from_pretrained(
              "facebook/bart-large-mnli"
          )
          self.tokenizer.max_seq_length = (
              self.cfg.dataset.max_seq_length
          )
  
imports: import os
  from collections import defaultdict
  from typing import Dict, List, Optional, Union
  import numpy
  import torch
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
  from nemo.collections.nlp.data.dialogue import DialogueSGDDataProcessor
  from nemo.collections.nlp.data.dialogue.data_processor.assistant_data_processor import DialogueAssistantDataProcessor
  from nemo.collections.nlp.data.dialogue.data_processor.design_data_processor import DialogueDesignDataProcessor
  from nemo.collections.nlp.data.dialogue.dataset.dialogue_zero_shot_intent_dataset import DialogueZeroShotIntentDataset
  from nemo.collections.nlp.data.zero_shot_intent_recognition.zero_shot_intent_dataset import ZeroShotIntentInferenceDataset, calc_class_weights_from_dataloader
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.metrics.dialogue_metrics import DialogueGenerationMetrics
  from nemo.collections.nlp.models import TextClassificationModel
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new DialogueZeroShotIntentModel object from inherited base classes: TextClassificationModel with example: obj = DialogueZeroShotIntentModel(cfg, trainer)