class_docstr: Designed for classification tasks such as intent/domain classification as well as slot tagging
  
  Dataset Class 
      1. Performs Model-dependent (but Data-independent) operations (tokenization etc)
      2. This can allow the same model preprocessing for multiple datasources
      3. Users can configurate which labels to use for modelling 
          (e.g. intent classification, slot filling or both together etc)
class_docstr_tok: ["Designed","for","classification","tasks","such","as","intent\/domain","classification","as","well","as","slot","tagging","Dataset","Class","1",".","Performs","Model-dependent","(","but","Data-independent",")","operations","(","tokenization","etc",")","2",".","This","can","allow","the","same","model","preprocessing","for","multiple","datasources","3",".","Users","can","configurate","which","labels","to","use","for","modelling","(","e.g",".","intent","classification",",","slot","filling","or","both","together","etc",")"]
docstr:         State how the input and output samples look like
  
          This template can be changed
  
          Training example: 
              e.g. <utterance> service: restaurant
              e.g. <task description> <utterance> service: restaurant
              e.g. <utterance>
  intent: set alarm
  slots: <slot_name1>(<slot_value1>), <slot_name1>(<slot_value1>)
  
          Generation example:
              e.g. <utterance> service: 
  
          
docstr_tok: ["State","how","the","input","and","output","samples","look","like","This","template","can","be","changed","Training","example",":","e.g",".","<","utterance",">","service",":","restaurant","e.g",".","<","task","description",">","<","utterance",">","service",":","restaurant","e.g",".","<","utterance",">","intent",":","set","alarm","slots",":","<","slot_name1",">","(","<","slot_value1",">",")",",","<","slot_name1",">","(","<","slot_value1",">",")","Generation","example",":","e.g",".","<","utterance",">","service",":"]
code: def __getitem__(self, idx: int):
      """
      State how the input and output samples look like
  
      This template can be changed
  
      Training example:
          e.g. <utterance> service: restaurant
          e.g. <task description> <utterance> service: restaurant
          e.g. <utterance>\nintent: set alarm\nslots: <slot_name1>(<slot_value1>), <slot_name1>(<slot_value1>)
  
      Generation example:
          e.g. <utterance> service:
  
      """
      ex = self.features[idx].data
  
      utterance = ex["utterance"]
      utterance_length = self.get_n_tokens_in_sentence(utterance)
  
      label = ex["labels"][self.label_type]
      candidates = ex["possible_labels"][self.label_type]
  
      slots = (
          ex["labels"]["slots"]
          if self.cfg.target_template == "with_slots"
          else None
      )
  
      base_template = self.format_prompt(
          utterance, few_shot=self.cfg.few_shot, idx=idx
      )
  
      sentence_without_answer = base_template
  
      sentence = (
          base_template + " " + self.format_target(label, slots=slots)
      )
  
      if self.cfg.eval_mode == "binary_score":
          candidate_sentences = []
          for candidate in candidates:
              positive_answer = (
                  base_template + " " + candidate + " Answer: " + "yes"
              )
              negative_answer = (
                  base_template + " " + candidate + " Answer: " + "no"
              )
              if candidate == label:
                  correct_candidate = len(candidate_sentences) // 2
                  candidate_sentences.append(positive_answer)
                  candidate_sentences.append(negative_answer)
              else:
                  candidate_sentences.append(negative_answer)
                  candidate_sentences.append(positive_answer)
      else:
          correct_candidate = 0
          candidate_sentences = [
              base_template
              + " "
              + self.format_target(candidate, slots=slots)
              for candidate in candidates
          ]
  
      encodings_dict, input_ids, attn_masks = self.default_encode(
          sentence
      )
  
      candidate_tokenized_sentences = [
          self.default_encode(candidate_sentence)
          for candidate_sentence in candidate_sentences
      ]
  
      # ensure all samples have the same number of candidates for collating into tensor
      while len(candidate_tokenized_sentences) < self.max_candidates:
          candidate_tokenized_sentences.append(
              candidate_tokenized_sentences[0]
          )
  
      candidate_input_ids = torch.stack(
          [i[1] for i in candidate_tokenized_sentences]
      )
      candidate_attn_masks = torch.stack(
          [i[2] for i in candidate_tokenized_sentences]
      )
  
      labels = copy.copy(torch.squeeze(encodings_dict["input_ids"]))
  
      training_mask_end = self.get_n_tokens_in_sentence(
          sentence_without_answer
      )
  
      labels.data = torch.tensor(
          [
              -100 if i < training_mask_end else labels.data[i]
              for i in range(len(labels.data))
          ]
      )
  
      return (
          input_ids,
          attn_masks,
          labels,
          candidate_input_ids,
          candidate_attn_masks,
          training_mask_end,
          utterance_length,
          correct_candidate,
      )
  
file_path: NeMo/nemo/collections/nlp/data/dialogue/dataset/dialogue_gpt_classification_dataset.py
imports: import copy
  import random
  from collections import defaultdict
  import torch
  from nemo.collections.nlp.data.dialogue.dataset.dialogue_dataset import DialogueDataset
  from nemo.utils import logging
label_desc: Use image node_id 12 for calling the DialogueGPTClassificationDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: input_ids,  attn_masks,  labels,  candidate_input_ids,  candidate_attn_masks,  training_mask_end,  utterance_length,  correct_candidate