class_docstr: This ``DatasetReader`` takes WikiTableQuestions ``*.examples`` files and converts them into
  ``Instances`` suitable for use with the ``WikiTablesSemanticParser``.  This reader also accepts
  pre-processed JSONL files produced by ``scripts/preprocess_wikitables.py``.  Processing the
  example files to read a bunch of individual table files, run NER on all of the tables, and
  convert logical forms into action sequences is quite slow, so we recommend you run the
  pre-processing script.  Having the same reader handle both file types allows you to train with
  a pre-processed file, but not have to change your model configuration in order to serve a demo
  from the trained model.
  
  The ``*.examples`` files have pointers in them to two other files: a file that contains an
  associated table for each question, and a file that has pre-computed, possible logical forms.
  Because of how the ``DatasetReader`` API works, we need to take base directories for those
  other files in the constructor.
  
  We initialize the dataset reader with paths to the tables directory and the directory where DPD
  output is stored if you are training. While testing, you can either provide existing table
  filenames or if your question is about a new table, provide the content of the table as a dict
  (See :func:`TableQuestionKnowledgeGraph.read_from_json` for the expected format). If you are
  doing the former, you still need to provide a ``tables_directory`` path here.
  
  For training, we assume you are reading in ``data/*.examples`` files, and you have access to
  the output from Dynamic Programming on Denotations (DPD) on the training dataset.
  
  We lowercase the question and all table text, because the questions in the data are typically
  all lowercase, anyway.  This makes it so that any live demo that you put up will have questions
  that match the data this was trained on.  Lowercasing the table text makes matching the
  lowercased question text easier.
  
  Parameters
  ----------
  lazy : ``bool`` (optional, default=False)
      Passed to ``DatasetReader``.  If this is ``True``, training will start sooner, but will
      take longer per batch.
  tables_directory : ``str``, optional
      Prefix for the path to the directory in which the tables reside. For example,
      ``*.examples`` files contain paths like ``csv/204-csv/590.csv``, this is the directory that
      contains the ``csv`` directory.  This is only optional for ``Predictors`` (i.e., in a
      demo), where you're only calling :func:`text_to_instance`.
  dpd_output_directory : ``str``, optional
      Directory that contains all the gzipped dpd output files. We assume the filenames match the
      example IDs (e.g.: ``nt-0.gz``).  This is required for training a model, but not required
      for prediction.
  max_dpd_logical_forms : ``int``, optional (default=10)
      We will use the first ``max_dpd_logical_forms`` logical forms as our target label.  Only
      applicable if ``dpd_output_directory`` is given.
  sort_dpd_logical_forms : ``bool``, optional (default=True)
      If ``True``, we will sort the logical forms in the DPD output by length before selecting
      the first ``max_dpd_logical_forms``.  This makes the data loading quite a bit slower, but
      results in better training data.
  max_dpd_tries : ``int``, optional
      Sometimes DPD just made bad choices about logical forms and gives us forms that we can't
      parse (most of the time these are very unlikely logical forms, because, e.g., it
      hallucinates a date or number from the table that's not in the question).  But we don't
      want to spend our time trying to parse thousands of bad logical forms.  We will try to
      parse only the first ``max_dpd_tries`` logical forms before giving up.  This also speeds up
      data loading time, because we don't go through the entire DPD file if it's huge (unless
      we're sorting the logical forms).  Only applicable if ``dpd_output_directory`` is given.
      Default is 20.
  keep_if_no_dpd : ``bool``, optional (default=False)
      If ``True``, we will keep instances we read that don't have DPD output.  If you want to
      compute denotation accuracy on the full dataset, you should set this to ``True``.
      Otherwise, your accuracy numbers will only reflect the subset of the data that has DPD
      output.
  tokenizer : ``Tokenizer``, optional
      Tokenizer to use for the questions. Will default to ``WordTokenizer()`` with Spacy's tagger
      enabled, as we use lemma matches as features for entity linking.
  question_token_indexers : ``Dict[str, TokenIndexer]``, optional
      Token indexers for questions. Will default to ``{"tokens": SingleIdTokenIndexer()}``.
  table_token_indexers : ``Dict[str, TokenIndexer]``, optional
      Token indexers for table entities. Will default to ``question_token_indexers`` (though you
      very likely want to use something different for these, as you can't rely on having an
      embedding for every table entity at test time).
  use_table_for_vocab : ``bool`` (optional, default=False)
      If ``True``, we will include table cell text in vocabulary creation.  The original parser
      did not do this, because the same table can appear multiple times, messing with vocab
      counts, and making you include lots of rare entities in your vocab.
  linking_feature_extractors : ``List[str]``, optional
      The list of feature extractors to use in the :class:`KnowledgeGraphField` when computing
      entity linking features.  See that class for more information.  By default, we will use all
      available feature extractors.
  include_table_metadata : ``bool`` (optional, default=False)
      This is necessary for pre-processing the data.  We output a jsonl file that has all of the
      information necessary for reading each instance, which includes the table contents itself.
      This flag tells the reader to include a ``table_metadata`` field that gets read by the
      pre-processing script.
  max_table_tokens : ``int``, optional
      If given, we will only keep this number of total table tokens.  This bounds the memory
      usage of the table representations, truncating cells with really long text.  We specify a
      total number of tokens, not a max cell text length, because the number of table entities
      varies.
  output_agendas : ``bool``, (optional, default=False)
      Should we output agenda fields? This needs to be true if you want to train a coverage based
      parser.
code: def _json_blob_to_instance(self, json_obj):
      question_tokens = self._read_tokens_from_json_list(
          json_obj["question_tokens"]
      )
      question_field = TextField(
          question_tokens, self._question_token_indexers
      )
      question_metadata = MetadataField(
          {"question_tokens": [x.text for x in question_tokens]}
      )
      table_knowledge_graph = (
          TableQuestionKnowledgeGraph.read_from_lines(
              json_obj["table_lines"], question_tokens
          )
      )
      entity_tokens = [
          self._read_tokens_from_json_list(token_list)
          for token_list in json_obj["entity_texts"]
      ]
      table_field = KnowledgeGraphField(
          table_knowledge_graph,
          question_tokens,
          tokenizer=None,
          token_indexers=self._table_token_indexers,
          entity_tokens=entity_tokens,
          linking_features=json_obj["linking_features"],
          include_in_vocab=self._use_table_for_vocab,
          max_table_tokens=self._max_table_tokens,
      )
      world = WikiTablesWorld(table_knowledge_graph)
      world_field = MetadataField(world)
  
      production_rule_fields = []
      for production_rule in world.all_possible_actions():
          _, rule_right_side = production_rule.split(" -> ")
          is_global_rule = not world.is_table_entity(rule_right_side)
          field = ProductionRuleField(production_rule, is_global_rule)
          production_rule_fields.append(field)
      action_field = ListField(production_rule_fields)
  
      example_string_field = MetadataField(
          json_obj["example_lisp_string"]
      )
  
      fields = {
          "question": question_field,
          "metadata": question_metadata,
          "table": table_field,
          "world": world_field,
          "actions": action_field,
          "example_lisp_string": example_string_field,
      }
  
      if "target_action_sequences" in json_obj or "agenda" in json_obj:
          action_map = dict((action.rule, i) for i, action in enumerate(action_field.field_list))  # type: ignore
      if "target_action_sequences" in json_obj:
          action_sequence_fields = []
          for sequence in json_obj["target_action_sequences"]:
              index_fields = []
              for production_rule in sequence:
                  index_fields.append(
                      IndexField(
                          action_map[production_rule], action_field
                      )
                  )
              action_sequence_fields.append(ListField(index_fields))
          fields["target_action_sequences"] = ListField(
              action_sequence_fields
          )
      if "agenda" in json_obj:
          agenda_index_fields = []
          for agenda_action in json_obj["agenda"]:
              agenda_index_fields.append(
                  IndexField(action_map[agenda_action], action_field)
              )
          fields["agenda"] = ListField(agenda_index_fields)
      return Instance(fields)
  
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import gzip
  import json
  import logging
  import os
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import JsonDict
  from allennlp.data.dataset_readers.dataset_reader import DatasetReader
  from allennlp.data.fields import Field, IndexField, KnowledgeGraphField, ListField
  from allennlp.data.fields import MetadataField, ProductionRuleField, TextField
  from allennlp.data.instance import Instance
  from allennlp.data.token_indexers import TokenIndexer, SingleIdTokenIndexer
  from allennlp.data.tokenizers import Token, Tokenizer, WordTokenizer
  from allennlp.data.tokenizers.word_splitter import SpacyWordSplitter
  from allennlp.semparse.contexts import TableQuestionKnowledgeGraph
  from allennlp.semparse.type_declarations import wikitables_type_declaration
  from allennlp.semparse.worlds import WikiTablesWorld
  from allennlp.semparse.worlds.world import ParsingError
  from io import open
label_desc: Use image node_id 6 for calling the WikiTablesDatasetReader obj's underlying member method code with example usage: obj._json_blob_to_instance(json_obj) and returns: Instance