class_docstr: ``DatasetReader`` for the NLVR domain. In addition to the usual methods for reading files and
  instances from text, this class contains a method for creating an agenda of actions that each
  sentence triggers, if needed. Note that we deal with the version of the dataset with structured
  representations of the synthetic images instead of the actual images themselves.
  
  We support multiple data formats here:
  1) The original json version of the NLVR dataset (http://lic.nlp.cornell.edu/nlvr/) where the
  format of each line in the jsonl file is
  ```
  "sentence": <sentence>,
  "label": <true/false>,
  "identifier": <id>,
  "evals": <dict containing all annotations>,
  "structured_rep": <list of three box representations, where each box is a list of object
  representation dicts, containing fields "x_loc", "y_loc", "color", "type", "size">
  ```
  
  2) A grouped version (constructed using ``scripts/nlvr/group_nlvr_worlds.py``) where we group
  all the worlds that a sentence appears in. We use the fields ``sentence``, ``label`` and
  ``structured_rep``.  And the format of the grouped files is
  ```
  "sentence": <sentence>,
  "labels": <list of labels corresponding to worlds the sentence appears in>
  "identifier": <id that is only the prefix from the original data>
  "worlds": <list of structured representations>
  ```
  
  3) A processed version that contains action sequences that lead to the correct denotations (or
  not), using some search. This format is very similar to the grouped format, and has the
  following extra field
  
  ```
  "correct_sequences": <list of lists of action sequences corresponding to logical forms that
  evaluate to the correct denotations>
  ```
  
  Parameters
  ----------
  lazy : ``bool`` (optional, default=False)
      Passed to ``DatasetReader``.  If this is ``True``, training will start sooner, but will
      take longer per batch.
  tokenizer : ``Tokenizer`` (optional)
      The tokenizer used for sentences in NLVR. Default is ``WordTokenizer``
  sentence_token_indexers : ``Dict[str, TokenIndexer]`` (optional)
      Token indexers for tokens in input sentences.
      Default is ``{"tokens": SingleIdTokenIndexer()}``
  nonterminal_indexers : ``Dict[str, TokenIndexer]`` (optional)
      Indexers for non-terminals in production rules. The default is to index terminals and
      non-terminals in the same way, but you may want to change it.
      Default is ``{"tokens": SingleIdTokenIndexer("rule_labels")}``
  terminal_indexers : ``Dict[str, TokenIndexer]`` (optional)
      Indexers for terminals in production rules. The default is to index terminals and
      non-terminals in the same way, but you may want to change it.
      Default is ``{"tokens": SingleIdTokenIndexer("rule_labels")}``
  output_agendas : ``bool`` (optional)
      If preparing data for a trainer that uses agendas, set this flag and the datset reader will
      output agendas.
class_docstr_tok: ["``","DatasetReader","``","for","the","NLVR","domain",".","In","addition","to","the","usual","methods","for","reading","files","and","instances","from","text",",","this","class","contains","a","method","for","creating","an","agenda","of","actions","that","each","sentence","triggers",",","if","needed",".","Note","that","we","deal","with","the","version","of","the","dataset","with","structured","representations","of","the","synthetic","images","instead","of","the","actual","images","themselves",".","We","support","multiple","data","formats","here",":","1",")","The","original","json","version","of","the","NLVR","dataset","(","http",":","\/\/lic.nlp.cornell.edu\/nlvr\/",")","where","the","format","of","each","line","in","the","jsonl","file","is","``","`","''","sentence","''",":","<","sentence",">",",","''","label","''",":","<","true\/false",">",",","''","identifier","''",":","<","id",">",",","''","evals","''",":","<","dict","containing","all","annotations",">",",","''","structured_rep","''",":","<","list","of","three","box","representations",",","where","each","box","is","a","list","of","object","representation","dicts",",","containing","fields","``","x_loc","''",",","``","y_loc","''",",","``","color","''",",","``","type","''",",","``","size","''",">","``","`","2",")","A","grouped","version","(","constructed","using","``","scripts\/nlvr\/group_nlvr_worlds.py","``",")","where","we","group","all","the","worlds","that","a","sentence","appears","in",".","We","use","the","fields","``","sentence","``",",","``","label","``","and","``","structured_rep","``",".","And","the","format","of","the","grouped","files","is","``","`","''","sentence","''",":","<","sentence",">",",","''","labels","''",":","<","list","of","labels","corresponding","to","worlds","the","sentence","appears","in",">","''","identifier","''",":","<","id","that","is","only","the","prefix","from","the","original","data",">","''","worlds","''",":","<","list","of","structured","representations",">","``","`","3",")","A","processed","version","that","contains","action","sequences","that","lead","to","the","correct","denotations","(","or","not",")",",","using","some","search",".","This","format","is","very","similar","to","the","grouped","format",",","and","has","the","following","extra","field","``","`","''","correct_sequences","''",":","<","list","of","lists","of","action","sequences","corresponding","to","logical","forms","that","evaluate","to","the","correct","denotations",">","``","`","Parameters","--","--","--","--","--","lazy",":","``","bool","``","(","optional",",","default=False",")","Passed","to","``","DatasetReader","``",".","If","this","is","``","True","``",",","training","will","start","sooner",",","but","will","take","longer","per","batch",".","tokenizer",":","``","Tokenizer","``","(","optional",")","The","tokenizer","used","for","sentences","in","NLVR",".","Default","is","``","WordTokenizer","``","sentence_token_indexers",":","``","Dict","[","str",",","TokenIndexer","]","``","(","optional",")","Token","indexers","for","tokens","in","input","sentences",".","Default","is","``","{","``","tokens","''",":","SingleIdTokenIndexer","(",")","}","``","nonterminal_indexers",":","``","Dict","[","str",",","TokenIndexer","]","``","(","optional",")","Indexers","for","non-terminals","in","production","rules",".","The","default","is","to","index","terminals","and","non-terminals","in","the","same","way",",","but","you","may","want","to","change","it",".","Default","is","``","{","``","tokens","''",":","SingleIdTokenIndexer","(","``","rule_labels","''",")","}","``","terminal_indexers",":","``","Dict","[","str",",","TokenIndexer","]","``","(","optional",")","Indexers","for","terminals","in","production","rules",".","The","default","is","to","index","terminals","and","non-terminals","in","the","same","way",",","but","you","may","want","to","change","it",".","Default","is","``","{","``","tokens","''",":","SingleIdTokenIndexer","(","``","rule_labels","''",")","}","``","output_agendas",":","``","bool","``","(","optional",")","If","preparing","data","for","a","trainer","that","uses","agendas",",","set","this","flag","and","the","datset","reader","will","output","agendas","."]
code: def _read(self, file_path):
      with open(file_path, "r") as data_file:
          logger.info(
              "Reading instances from lines in file: %s", file_path
          )
          for line in data_file:
              line = line.strip("\n")
              if not line:
                  continue
              data = json.loads(line)
              sentence = data["sentence"]
              identifier = (
                  data["identifier"]
                  if "identifier" in data
                  else data["id"]
              )
              if "worlds" in data:
                  # This means that we are reading grouped nlvr data. There will be multiple
                  # worlds and corresponding labels per sentence.
                  labels = data["labels"]
                  structured_representations = data["worlds"]
              else:
                  # We will make lists of labels and structured representations, each with just
                  # one element for consistency.
                  labels = [data["label"]]
                  structured_representations = [data["structured_rep"]]
  
              target_sequences = None
              # TODO(pradeep): The processed file also has incorrect sequences as well, which are
              # needed if we want to define some sort of a hinge-loss based trainer. Deal with
              # them.
              if "correct_sequences" in data:
                  # We are reading the processed file and these are the "correct" logical form
                  # sequences. See ``scripts/nlvr/get_nlvr_logical_forms.py``.
                  target_sequences = data["correct_sequences"]
              instance = self.text_to_instance(
                  sentence,
                  structured_representations,
                  labels,
                  target_sequences,
                  identifier,
              )
              if instance is not None:
                  yield instance
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/dataset_readers/nlvr.py
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import json
  import logging
  from allennlp.common.util import JsonDict
  from allennlp.data.instance import Instance
  from allennlp.data.fields import Field, TextField, ListField, IndexField, LabelField
  from allennlp.data.fields import ProductionRuleField, MetadataField
  from allennlp.data.tokenizers import Tokenizer, WordTokenizer
  from allennlp.data.token_indexers import TokenIndexer, SingleIdTokenIndexer
  from allennlp.data.dataset_readers.dataset_reader import DatasetReader
  from allennlp.semparse.worlds import NlvrWorld
  from io import open
label_desc: Use image node_id 2 for calling the NlvrDatasetReader obj's underlying member method code with example usage: obj._read(file_path) without return types