class_docstr: Creates SQuAD dataset for Question Answering.
  Args:
      data_file (str): train.*.json eval.*.json or test.*.json.
      tokenizer (obj): Tokenizer object, e.g. AutoTokenizer.
      version_2_with_negative (bool): True if training should allow
          unanswerable questions.
      doc_stride (int): When splitting up a long document into chunks,
          how much stride to take between chunks.
      max_query_length (iny): All training files which have a duration less
          than min_duration are dropped. Can't be used if the `utt2dur` file
          does not exist. Defaults to None.
      max_seq_length (int): All training files which have a duration more
          than max_duration are dropped. Can't be used if the `utt2dur` file
          does not exist. Defaults to None.
      num_samples: number of samples you want to use for the dataset.
          If -1, use all dataset. Useful for testing.
      mode (str): Use TRAINING_MODE/EVALUATION_MODE/INFERENCE_MODE to define between
          training, evaluation and inference dataset.
      use_cache (bool): Caches preprocessed data for future usage
class_docstr_tok: ["Creates","SQuAD","dataset","for","Question","Answering",".","Args",":","data_file","(","str",")",":","train",".","*",".json","eval",".","*",".json","or","test.","*",".json",".","tokenizer","(","obj",")",":","Tokenizer","object",",","e.g",".","AutoTokenizer",".","version_2_with_negative","(","bool",")",":","True","if","training","should","allow","unanswerable","questions",".","doc_stride","(","int",")",":","When","splitting","up","a","long","document","into","chunks",",","how","much","stride","to","take","between","chunks",".","max_query_length","(","iny",")",":","All","training","files","which","have","a","duration","less","than","min_duration","are","dropped",".","Ca","n't","be","used","if","the","`","utt2dur","`","file","does","not","exist",".","Defaults","to","None",".","max_seq_length","(","int",")",":","All","training","files","which","have","a","duration","more","than","max_duration","are","dropped",".","Ca","n't","be","used","if","the","`","utt2dur","`","file","does","not","exist",".","Defaults","to","None",".","num_samples",":","number","of","samples","you","want","to","use","for","the","dataset",".","If","-1",",","use","all","dataset",".","Useful","for","testing",".","mode","(","str",")",":","Use","TRAINING_MODE\/EVALUATION_MODE\/INFERENCE_MODE","to","define","between","training",",","evaluation","and","inference","dataset",".","use_cache","(","bool",")",":","Caches","preprocessed","data","for","future","usage"]
code: def __init__(
      self,
      data_file: str,
      keep_doc_spans: str,
      tokenizer: object,
      doc_stride: int,
      max_query_length: int,
      max_seq_length: int,
      version_2_with_negative: bool,
      num_samples: int,
      mode: str,
      use_cache: bool,
  ):
      self.tokenizer = tokenizer
      self.version_2_with_negative = version_2_with_negative
      self.processor = SquadProcessor(data_file=data_file, mode=mode)
      self.mode = mode
      self.keep_doc_spans = keep_doc_spans
  
      # hashing to reduce memory use
      self.input_mask_id = 0
      self.input_mask_id_to_input_mask = {}
      self.input_mask_to_input_mask_id = {}
  
      self.segment_mask_id = 0
      self.segment_mask_id_to_segment_mask = {}
      self.segment_mask_to_segment_mask_id = {}
  
      if mode not in [TRAINING_MODE, EVALUATION_MODE, INFERENCE_MODE]:
          raise ValueError(
              f"mode should be either {TRAINING_MODE}, {EVALUATION_MODE}, {INFERENCE_MODE} but got {mode}"
          )
      self.examples = self.processor.get_examples()
  
      vocab_size = getattr(tokenizer, "vocab_size", 0)
      cached_features_file = (
          data_file
          + "_cache"
          + "_{}_{}_{}_{}_{}_{}_{}".format(
              mode,
              tokenizer.name,
              str(vocab_size),
              str(max_seq_length),
              str(doc_stride),
              str(max_query_length),
              str(num_samples),
          )
      )
  
      # check number of samples. Should be either -1 not to limit or positive number
      if num_samples == 0:
          raise ValueError(
              f"num_samples has to be positive or -1 (to use the entire dataset), however got {num_samples}."
          )
      elif num_samples > 0:
          self.examples = self.examples[:num_samples]
  
      if use_cache and os.path.exists(cached_features_file):
          logging.info(f"loading from {cached_features_file}")
          # delete self.examples during training mode to save memory
          if self.mode == TRAINING_MODE:
              del self.examples
              del self.processor
  
          with open(cached_features_file, "rb") as reader:
              items_to_pickle = pickle.load(reader)
              (
                  self.features,
                  self.input_mask_id_to_input_mask,
                  self.input_mask_to_input_mask_id,
                  self.segment_mask_id_to_segment_mask,
                  self.segment_mask_to_segment_mask_id,
              ) = items_to_pickle
              items_to_pickle = None
              del items_to_pickle
  
      else:
          logging.info(f"Preprocessing data.")
  
          self.features = self.convert_examples_to_features(
              examples=self.examples,
              tokenizer=tokenizer,
              max_seq_length=max_seq_length,
              doc_stride=doc_stride,
              max_query_length=max_query_length,
              has_groundtruth=mode != INFERENCE_MODE,
          )
  
          if use_cache:
              master_device = (
                  not torch.distributed.is_initialized()
                  or torch.distributed.get_rank() == 0
              )
              if master_device:
                  logging.info(
                      "  Saving train features into cached file %s",
                      cached_features_file,
                  )
                  with open(cached_features_file, "wb") as writer:
                      items_to_pickle = [
                          self.features,
                          self.input_mask_id_to_input_mask,
                          self.input_mask_to_input_mask_id,
                          self.segment_mask_id_to_segment_mask,
                          self.segment_mask_to_segment_mask_id,
                      ]
                      pickle.dump(items_to_pickle, writer)
  
          # delete self.examples during training mode to save memory
          if self.mode == TRAINING_MODE:
              self.examples = []
              del self.processor
  
      logging.info("Converting dict features into object features")
      for i in trange(len(self.features)):
          self.features[i] = InputFeatures(**self.features[i])
  
imports: import collections
  import os
  import pickle
  from functools import lru_cache
  from typing import Dict, List, Optional
  import numpy
  import psutil
  import torch
  from tqdm import trange
  from nemo.collections.common.parts.utils import _compute_softmax
  from nemo.collections.nlp.data.data_utils import is_whitespace
  from nemo.collections.nlp.data.question_answering_squad.qa_squad_processing import EVALUATION_MODE, INFERENCE_MODE, TRAINING_MODE, SquadProcessor, _improve_answer_span, apply_no_ans_threshold, exact_match_score, f1_score, find_all_best_thresh, get_best_indexes, get_final_text, make_eval_dict, merge_eval, normalize_answer
  from nemo.core.classes import Dataset
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new SquadDataset object from inherited base classes: Dataset with example: obj = SquadDataset(data_file, keep_doc_spans, tokenizer, doc_stride, max_query_length, max_seq_length, version_2_with_negative, num_samples, mode, use_cache)