class_docstr: Defines a batch of examples along with its Fields.
  
  Attributes:
      batch_size: Number of examples in the batch.
      dataset: A reference to the dataset object the examples come from
          (which itself contains the dataset's Field objects).
      train: Deprecated: this attribute is left for backwards compatibility,
          however it is UNUSED as of the merger with pytorch 0.4.
      input_fields: The names of the fields that are used as input for the model
      target_fields: The names of the fields that are used as targets during
                     model training
  
  Also stores the Variable for each column in the batch as an attribute.
class_docstr_tok: ["Defines","a","batch","of","examples","along","with","its","Fields",".","Attributes",":","batch_size",":","Number","of","examples","in","the","batch",".","dataset",":","A","reference","to","the","dataset","object","the","examples","come","from","(","which","itself","contains","the","dataset","'s","Field","objects",")",".","train",":","Deprecated",":","this","attribute","is","left","for","backwards","compatibility",",","however","it","is","UNUSED","as","of","the","merger","with","pytorch","0.4.","input_fields",":","The","names","of","the","fields","that","are","used","as","input","for","the","model","target_fields",":","The","names","of","the","fields","that","are","used","as","targets","during","model","training","Also","stores","the","Variable","for","each","column","in","the","batch","as","an","attribute","."]
docstr: Create a Batch from a list of examples.
docstr_tok: ["Create","a","Batch","from","a","list","of","examples","."]
code: def __init__(self, data=None, dataset=None, device=None):
      """Create a Batch from a list of examples."""
      if data is not None:
          self.batch_size = len(data)
          self.dataset = dataset
          self.fields = dataset.fields.keys()  # copy field names
          self.input_fields = [
              k
              for k, v in dataset.fields.items()
              if v is not None and not v.is_target
          ]
          self.target_fields = [
              k
              for k, v in dataset.fields.items()
              if v is not None and v.is_target
          ]
  
          for name, field in dataset.fields.items():
              if field is not None:
                  batch = [getattr(x, name) for x in data]
                  setattr(
                      self, name, field.process(batch, device=device)
                  )
  
file_path: pytext/pytext/legacy/data/batch.py
imports: import torch
label_desc: Use image node_id 1 to create a new Batch object from inherited base classes: object with example: obj = Batch(data, dataset, device)