class_docstr: The base teacher class for Natural Questions dataset challenge.
  
  This class implements the core functionalities for other teachers. The other four
  variations of teachers are made by setting two object attributes (use_html,
  use_long_answer) to either True or False.
class_docstr_tok: ["The","base","teacher","class","for","Natural","Questions","dataset","challenge",".","This","class","implements","the","core","functionalities","for","other","teachers",".","The","other","four","variations","of","teachers","are","made","by","setting","two","object","attributes","(","use_html",",","use_long_answer",")","to","either","True","or","False","."]
docstr: Loads from a chunk of the dataset, given the chunk index.
  
  Returns a list of dictionaries. Each dictionary is an example from the
      main dataset and stores the components of that examples (e.g.,
      contenxt, question, candidate answers etc.) as key-value pairs.
  
  :param chunk_idx: the index of the chunk dataset chunk file.
docstr_tok: ["Loads","from","a","chunk","of","the","dataset",",","given","the","chunk","index",".","Returns","a","list","of","dictionaries",".","Each","dictionary","is","an","example","from","the","main","dataset","and","stores","the","components","of","that","examples","(","e.g.",",","contenxt",",","question",",","candidate","answers","etc",".",")","as","key-value","pairs",".",":","param","chunk_idx",":","the","index","of","the","chunk","dataset","chunk","file","."]
code: def load_from_chunk(self, chunk_idx: int):
      """
      Loads from a chunk of the dataset, given the chunk index.
  
      Returns a list of dictionaries. Each dictionary is an example from the
          main dataset and stores the components of that examples (e.g.,
          contenxt, question, candidate answers etc.) as key-value pairs.
  
      :param chunk_idx: the index of the chunk dataset chunk file.
      """
  
      def _extract_labels_indices(example, candidate_labels):
          labels = []
          for label in example["annotations"]:
              label_ind = label["long_answer"]["candidate_index"]
              labels.append(candidate_labels[label_ind])
          return labels
  
      fname = self._get_fname(chunk_idx)
      fpath = os.path.join(self.dpath, fname)
      output = []
      with jsonlines.open(fpath, "r") as fi:
          for example in fi:
              example_components = dict()
              example = self._simplify(example)
              question = example["question_text"]
              if self.use_context:
                  context = example[_context_type_key(self.use_html)]
                  example_components["text"] = f"{context}\n{question}?"
              else:
                  example_components["text"] = f"{question}?"
  
              if self.use_long_answer:
                  example_components[
                      "long_answers_candidate"
                  ] = self._get_candidate_long_answers(example)
                  example_components[
                      "long_answers"
                  ] = _extract_labels_indices(
                      example,
                      example_components["long_answers_candidate"],
                  )
              else:
                  example_components[
                      "short_answers"
                  ] = self._get_short_answers(example)
              output.append(example_components)
      return output
  
imports: import copy
  import os
  import json
  import jsonlines
  from typing import List, Optional, Tuple
  from parlai.core.teachers import ChunkTeacher, DialogTeacher
  from .build import build, DATASET_NAME_LOCAL, build_sample
  from .build_open import build
  from .utils.text_utils import simplify_nq_example
  from parlai.core.opt import Opt
  from parlai.core.message import Message
  from parlai.core.metrics import ExactMatchMetric, normalize_answer, AverageMetric
  from parlai.core.params import ParlaiParser
  from parlai.utils.data import DatatypeHelper
  from parlai.utils.io import PathManager
  import parlai.utils.logging
label_desc: Use image node_id 10 for calling the NaturalQuestionsTeacher obj's underlying member method code with example usage: obj.load_from_chunk(chunk_idx) and returns: output, labels