class_docstr: The base dataset class for prompt-tuning or p-tuning.
  TODO: (@adithyare) should be merged into GPTPromptLearningDataset
class_docstr_tok: ["The","base","dataset","class","for","prompt-tuning","or","p-tuning",".","TODO",":","(","@","adithyare",")","should","be","merged","into","GPTPromptLearningDataset"]
docstr: Try to truncate input text to fit into the max sequence length 
docstr_tok: ["Try","to","truncate","input","text","to","fit","into","the","max","sequence","length"]
code: def _truncate_input(
      self,
      truncation_field,
      input_ids,
      taskname,
      doc,
      total_virtual_tokens=0,
  ):
      """Try to truncate input text to fit into the max sequence length"""
      logging.info(
          f"Input greater than max sequence length. Attempting to truncate: '{truncation_field}' in task: '{taskname}'"
      )
  
      # Truncate the text ids in this part of input to try and fit max sequence length
      if (
          truncation_field is not None
          and truncation_field in doc.keys()
      ):
          truncation_length = len(input_ids) - self.max_seq_length
          field_text = doc[truncation_field]
          field_text = self._add_leading_space(
              taskname, truncation_field, field_text
          )
  
          # Truncate field text
          field_text_ids = self.tokenizer.text_to_ids(field_text)
          truncated_text_ids = field_text_ids[
              : -min(truncation_length, len(field_text_ids))
          ]
  
          # Replace original text ids with truncated text ids
          field_start, field_end = find_subsequence_location(
              input_ids, field_text_ids
          )
          input_ids = (
              input_ids[:field_start]
              + truncated_text_ids
              + input_ids[field_end + 1 :]
          )
      else:
          if not self.for_train:
              # Hack alert! Slash and burn
              #  @TODO (@adithyare) need a more graceful truncation here, we should not skip examples in test
              input_ids = (
                  input_ids[:total_virtual_tokens]
                  + input_ids[total_virtual_tokens:][
                      -self.max_seq_length + total_virtual_tokens :
                  ]
              )
  
      return input_ids
  
file_path: NeMo/nemo/collections/nlp/data/language_modeling/megatron/base_prompt_learning_dataset.py
imports: import torch
  from nemo.collections.nlp.modules.common import VirtualPromptSource
  from nemo.core import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling the BasePromptLearningDataset obj's underlying member method code with example usage: obj._truncate_input(truncation_field, input_ids, taskname, doc, total_virtual_tokens) and returns: input_ids