class_docstr: The dataset class for prompt-tuning or p-tuning pretrained GPT models.
  
  Args:
      data (list[strings], list[dicts]): (1) paths to .jsonl or .json files, (2) dict objects corresponding to each input example
      tokenizer (tokenizer): Tokenizer from frozen language model
      virtual_prompt_source (Enum): Either VirtualPromptSource.NO_PROMPTS or VirtualPromptSource.PROMPT_ENCODER
      task_templates (dict): Dictionary containing all task template information needed to format prompts. Created in the GPTPromptLearningModel class.
      pseudo_tokens (list[strings]): A list of virtual prompt token placeholders e.g [<prompt_1>, <prompt_2>, ...] up to max num virtual tokens
      pad_token_id (int): ID of pad token from tokenizer
      max_seq_length (int): maximum sequence length for each dataset examples. Examples will either be truncated to fit this length or dropped if they cannot be truncated.
      min_seq_length (int): min length of each data example in the dataset. Data examples will be dropped if they do not meet the min length requirements. 
      add_bos (bool): Whether to add a beginning of sentence token to each data example
      add_eos (bool): Whether to add an end of sentence token to each data example
      for_train (bool): Whether you're creating a dataset for training or inference
      tokens_to_generate (int): (inference only) Number of tokens to generate during inference
docstr: Loads a dataset by filling in the task templates specified in the config file
  with the information from each training/inference example. Converts all input 
  text into token ids. Also replaces the <|VIRTUAL_PROMPT_#|> placeholders in 
  the task templates with the actual virtual prompt token ids. 
  
  params:
      dataset: A list of json objects or a dictionary objects each
               containing the information needed for a training example
docstr_tok: ["Loads","a","dataset","by","filling","in","the","task","templates","specified","in","the","config","file","with","the","information","from","each","training\/inference","example",".","Converts","all","input","text","into","token","ids",".","Also","replaces","the","<","|VIRTUAL_PROMPT_","#","|",">","placeholders","in","the","task","templates","with","the","actual","virtual","prompt","token","ids",".","params",":","dataset",":","A","list","of","json","objects","or","a","dictionary","objects","each","containing","the","information","needed","for","a","training","example"]
code: def load_data(self, dataset):
      """
      Loads a dataset by filling in the task templates specified in the config file
      with the information from each training/inference example. Converts all input
      text into token ids. Also replaces the <|VIRTUAL_PROMPT_#|> placeholders in
      the task templates with the actual virtual prompt token ids.
  
      params:
          dataset: A list of json objects or a dictionary objects each
                   containing the information needed for a training example
      """
      skipped = 0
  
      for json_line in tqdm(dataset):
          # Read example dict or load the information for a single example from .json file
          if type(json_line) == dict:
              doc = json_line
          else:
              doc = json.loads(json_line)
  
          taskname = doc["taskname"]
          prompt_template = self.task_templates[taskname][
              "prompt_template"
          ]
          prompt_template_fields = self.task_templates[taskname][
              "prompt_template_fields"
          ]
          total_virtual_tokens = self.task_templates[taskname][
              "total_virtual_tokens"
          ]
          virtual_token_splits = self.task_templates[taskname][
              "virtual_token_splits"
          ]
          truncation_field = self.task_templates[taskname][
              "truncate_field"
          ]
          answer_only_loss = self.task_templates[taskname][
              "answer_only_loss"
          ]
          answer_field = self.task_templates[taskname]["answer_field"]
  
          input_example = prompt_template
  
          self._input_sanity_checks(
              total_virtual_tokens,
              virtual_token_splits,
              prompt_template,
              prompt_template_fields,
              truncation_field,
              answer_only_loss,
              answer_field,
              doc,
          )
  
          # Format the input example according to the template
          input_example = self._insert_text_in_template(
              input_example, prompt_template_fields, doc
          )
          input_example = self._insert_virtual_token_placeholders(
              input_example, virtual_token_splits
          )
          input_ids = self.tokenizer.text_to_ids(input_example)
  
          # Add BOS/EOS if desired, adds EOS by default
          if self.add_bos:
              input_ids = [self.tokenizer.bos_id] + input_ids
          if self.add_eos:
              input_ids = input_ids + [self.tokenizer.eos_id]
  
          # Try to truncate input text to fit into the max sequence length
          if len(input_ids) > self.max_seq_length:
              input_ids = self._truncate_input(
                  truncation_field,
                  input_ids,
                  taskname,
                  doc,
                  prompt_template,
                  prompt_template_fields,
                  virtual_token_splits,
              )
  
          # Skip example if the final length doesn't fit length requirements even after truncation
          if (
              self.min_seq_length
              <= len(input_ids)
              <= self.max_seq_length
          ):
              if (
                  self.virtual_prompt_source
                  == VirtualPromptSource.PROMPT_ENCODER
              ):
                  taskname_id = self.tokenizer.text_to_ids(taskname)
              elif (
                  self.virtual_prompt_source
                  == VirtualPromptSource.NO_PROMPT
              ):
                  taskname_id = -1
              else:
                  raise ValueError(
                      "Invalid virtual prompt source specified"
                  )
  
              # Find answer field indices if training and answer_only_loss is True
              answer_start_idx = None
              if answer_only_loss and self.for_train:
                  answer_start_idx = self._find_answer_start(
                      taskname, input_ids, answer_field, doc
                  )
  
              self.examples.append(
                  (taskname_id, input_ids, answer_start_idx)
              )
          else:
              skipped += 1
  
      logging.info(
          f"Skipped {skipped} sentences, sequence length too short or too long even after truncation"
      )
  
imports: import json
  import os
  import pickle
  import torch
  from tqdm.auto import tqdm
  from nemo.collections.nlp.modules.common import VirtualPromptSource
  from nemo.collections.nlp.modules.common.megatron.utils import build_position_ids
  from nemo.core import Dataset
  from nemo.utils import AppState, logging
label_desc: Use image node_id 2 for calling the GPTPromptLearningDataset obj's underlying member method code with example usage: obj.load_data(dataset) without return types