class_docstr: An `Instance` is a collection of :class:`~allennlp.data.fields.field.Field` objects,
  specifying the inputs and outputs to
  some model.  We don't make a distinction between inputs and outputs here, though - all
  operations are done on all fields, and when we return arrays, we return them as dictionaries
  keyed by field name.  A model can then decide which fields it wants to use as inputs as which
  as outputs.
  
  The `Fields` in an `Instance` can start out either indexed or un-indexed.  During the data
  processing pipeline, all fields will be indexed, after which multiple instances can be combined
  into a `Batch` and then converted into padded arrays.
  
  # Parameters
  
  fields : `Dict[str, Field]`
      The `Field` objects that will be used to produce data arrays for this instance.
class_docstr_tok: ["An","`","Instance","`","is","a","collection","of",":","class",":","`","~allennlp.data.fields.field.Field","`","objects",",","specifying","the","inputs","and","outputs","to","some","model",".","We","do","n't","make","a","distinction","between","inputs","and","outputs","here",",","though","-","all","operations","are","done","on","all","fields",",","and","when","we","return","arrays",",","we","return","them","as","dictionaries","keyed","by","field","name",".","A","model","can","then","decide","which","fields","it","wants","to","use","as","inputs","as","which","as","outputs",".","The","`","Fields","`","in","an","`","Instance","`","can","start","out","either","indexed","or","un-indexed",".","During","the","data","processing","pipeline",",","all","fields","will","be","indexed",",","after","which","multiple","instances","can","be","combined","into","a","`","Batch","`","and","then","converted","into","padded","arrays",".","#","Parameters","fields",":","`","Dict","[","str",",","Field","]","`","The","`","Field","`","objects","that","will","be","used","to","produce","data","arrays","for","this","instance","."]
docstr: Indexes all fields in this `Instance` using the provided `Vocabulary`.
  This `mutates` the current object, it does not return a new `Instance`.
  A `DataLoader` will call this on each pass through a dataset; we use the `indexed`
  flag to make sure that indexing only happens once.
  
  This means that if for some reason you modify your vocabulary after you've
  indexed your instances, you might get unexpected behavior.
docstr_tok: ["Indexes","all","fields","in","this","`","Instance","`","using","the","provided","`","Vocabulary","`",".","This","`","mutates","`","the","current","object",",","it","does","not","return","a","new","`","Instance","`",".","A","`","DataLoader","`","will","call","this","on","each","pass","through","a","dataset",";","we","use","the","`","indexed","`","flag","to","make","sure","that","indexing","only","happens","once",".","This","means","that","if","for","some","reason","you","modify","your","vocabulary","after","you've","indexed","your","instances",",","you","might","get","unexpected","behavior","."]
code: def index_fields(self, vocab: Vocabulary) -> None:
      """
      Indexes all fields in this `Instance` using the provided `Vocabulary`.
      This `mutates` the current object, it does not return a new `Instance`.
      A `DataLoader` will call this on each pass through a dataset; we use the `indexed`
      flag to make sure that indexing only happens once.
  
      This means that if for some reason you modify your vocabulary after you've
      indexed your instances, you might get unexpected behavior.
      """
      if not self.indexed:
          for field in self.fields.values():
              field.index(vocab)
          self.indexed = True
  
file_path: allennlp/allennlp/data/instance.py
imports: from typing import Dict, MutableMapping, Mapping
  from allennlp.data.fields.field import DataArray, Field
  from allennlp.data.vocabulary import Vocabulary
  from allennlp.common.util import JsonDict
label_desc: Use image node_id 7 for calling the Instance obj's underlying member method code with example usage: obj.index_fields(vocab) without return types