class_docstr: A ``DatasetReader`` knows how to turn a file containing a dataset into a collection
  of ``Instance`` s.  To implement your own, just override the `_read(file_path)` method
  to return an ``Iterable`` of the instances. This could be a list containing the instances
  or a lazy generator that returns them one at a time.
  
  All parameters necessary to _read the data apart from the filepath should be passed
  to the constructor of the ``DatasetReader``.
  
  Parameters
  ----------
  lazy : ``bool``, optional (default=False)
      If this is true, ``instances()`` will return an object whose ``__iter__`` method
      reloads the dataset each time it's called. Otherwise, ``instances()`` returns a list.
class_docstr_tok: ["A","``","DatasetReader","``","knows","how","to","turn","a","file","containing","a","dataset","into","a","collection","of","``","Instance","``","s.","To","implement","your","own",",","just","override","the","`","_read","(","file_path",")","`","method","to","return","an","``","Iterable","``","of","the","instances",".","This","could","be","a","list","containing","the","instances","or","a","lazy","generator","that","returns","them","one","at","a","time",".","All","parameters","necessary","to","_read","the","data","apart","from","the","filepath","should","be","passed","to","the","constructor","of","the","``","DatasetReader","``",".","Parameters","--","--","--","--","--","lazy",":","``","bool","``",",","optional","(","default=False",")","If","this","is","true",",","``","instances","(",")","``","will","return","an","object","whose","``","__iter__","``","method","reloads","the","dataset","each","time","it","'s","called",".","Otherwise",",","``","instances","(",")","``","returns","a","list","."]
docstr: Returns an ``Iterable`` containing all the instances
  in the specified dataset.
  
  If ``self.lazy`` is False, this calls ``self._read()``,
  ensures that the result is a list, then returns the resulting list.
  
  If ``self.lazy`` is True, this returns an object whose
  ``__iter__`` method calls ``self._read()`` each iteration.
  In this case your implementation of ``_read()`` must also be lazy
  (that is, not load all instances into memory at once), otherwise
  you will get a ``ConfigurationError``.
  
  In either case, the returned ``Iterable`` can be iterated
  over multiple times. It's unlikely you want to override this function,
  but if you do your result should likewise be repeatedly iterable.
docstr_tok: ["Returns","an","``","Iterable","``","containing","all","the","instances","in","the","specified","dataset",".","If","``","self.lazy","``","is","False",",","this","calls","``","self._read","(",")","``",",","ensures","that","the","result","is","a","list",",","then","returns","the","resulting","list",".","If","``","self.lazy","``","is","True",",","this","returns","an","object","whose","``","__iter__","``","method","calls","``","self._read","(",")","``","each","iteration",".","In","this","case","your","implementation","of","``","_read","(",")","``","must","also","be","lazy","(","that","is",",","not","load","all","instances","into","memory","at","once",")",",","otherwise","you","will","get","a","``","ConfigurationError","``",".","In","either","case",",","the","returned","``","Iterable","``","can","be","iterated","over","multiple","times",".","It","'s","unlikely","you","want","to","override","this","function",",","but","if","you","do","your","result","should","likewise","be","repeatedly","iterable","."]
code: def read(self, file_path):
      """
      Returns an ``Iterable`` containing all the instances
      in the specified dataset.
  
      If ``self.lazy`` is False, this calls ``self._read()``,
      ensures that the result is a list, then returns the resulting list.
  
      If ``self.lazy`` is True, this returns an object whose
      ``__iter__`` method calls ``self._read()`` each iteration.
      In this case your implementation of ``_read()`` must also be lazy
      (that is, not load all instances into memory at once), otherwise
      you will get a ``ConfigurationError``.
  
      In either case, the returned ``Iterable`` can be iterated
      over multiple times. It's unlikely you want to override this function,
      but if you do your result should likewise be repeatedly iterable.
      """
      lazy = getattr(self, "lazy", None)
      if lazy is None:
          logger.warning(
              "DatasetReader.lazy is not set, "
              "did you forget to call the superclass constructor?"
          )
  
      if lazy:
          return _LazyInstances(lambda: iter(self._read(file_path)))
      else:
          instances = self._read(file_path)
          if not isinstance(instances, list):
              instances = [
                  instance for instance in Tqdm.tqdm(instances)
              ]
          if not instances:
              raise ConfigurationError(
                  "No instances were read from the given filepath {}. "
                  "Is the path correct?".format(file_path)
              )
          return instances
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/dataset_readers/dataset_reader.py
imports: from __future__ import absolute_import
  import logging
  from allennlp.data.instance import Instance
  from allennlp.common import Tqdm
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.registrable import Registrable
label_desc: Use image node_id 2 for calling the DatasetReader obj's underlying member method code with example usage: obj.read(file_path) and returns: _LazyInstances, instances