class_docstr: BatchIterator is a wrapper of TorchText. Iterator that provide flexibility to
  map batched data to a tuple of (input, target, context) and other additional
  steps such as dealing with distributed training.
  
  Args:
      batches (Iterator[TorchText.Batch]): iterator of TorchText.Batch, which
          shuffles/batches the data in __iter__ and return a batch of data in
          __next__
      processor: function to run after getting batched data from TorchText.Iterator,
          the function should define a way to map to data into
          (input, target, context)
      include_input (bool): if input data should be returned, default is true
      include_target (bool): if target data should be returned, default is true
      include_context (bool): if context data should be returned, default is true
      is_train (bool): if the batch data is for training
      num_batches (int): total batches to generate, this param if for distributed
          training due to a limitation in PyTorch's distributed training backend
          that enforces all the parallel workers to have the same number of batches
          we workaround it by adding dummy batches at the end
class_docstr_tok: ["BatchIterator","is","a","wrapper","of","TorchText",".","Iterator","that","provide","flexibility","to","map","batched","data","to","a","tuple","of","(","input",",","target",",","context",")","and","other","additional","steps","such","as","dealing","with","distributed","training",".","Args",":","batches","(","Iterator","[","TorchText.Batch","]",")",":","iterator","of","TorchText.Batch",",","which","shuffles\/batches","the","data","in","__iter__","and","return","a","batch","of","data","in","__next__","processor",":","function","to","run","after","getting","batched","data","from","TorchText.Iterator",",","the","function","should","define","a","way","to","map","to","data","into","(","input",",","target",",","context",")","include_input","(","bool",")",":","if","input","data","should","be","returned",",","default","is","true","include_target","(","bool",")",":","if","target","data","should","be","returned",",","default","is","true","include_context","(","bool",")",":","if","context","data","should","be","returned",",","default","is","true","is_train","(","bool",")",":","if","the","batch","data","is","for","training","num_batches","(","int",")",":","total","batches","to","generate",",","this","param","if","for","distributed","training","due","to","a","limitation","in","PyTorch","'s","distributed","training","backend","that","enforces","all","the","parallel","workers","to","have","the","same","number","of","batches","we","workaround","it","by","adding","dummy","batches","at","the","end"]
code: def __init__(
      self,
      batches,
      processor,
      include_input=True,
      include_target=True,
      include_context=True,
      is_train=True,
      num_batches=0,
  ):
      self.processor = processor
      self.batches = batches
      self.include_input = include_input
      self.include_target = include_target
      self.include_context = include_context
      self.is_train = is_train
      self.total_num_batches = num_batches
  
imports: import csv
  import math
  import multiprocessing
  from copy import deepcopy
  from typing import Any, Dict, Generator, Iterable, List, MutableMapping, Optional, Set, Tuple, Type, Union
  import torch
  from pytext.common.constants import BatchContext, DatasetFieldName, DFColumn, VocabMeta
  from pytext.config.component import Component, ComponentType
  from pytext.config.field_config import Target
  from pytext.config.pytext_config import ConfigBase
  from pytext.data.featurizer import Featurizer
  from pytext.fields import Field, FieldMeta, RawField, VocabUsingField
  from pytext.legacy import data
  from pytext.utils import cuda, distributed
  from pytext.utils.data import parse_json_array
  from pytext.utils.file_io import PathManager
  from pytext.utils.path import get_absolute_path
  from pytext.utils.usage import log_class_usage
  from pytorch.text.fb.utils import embeddings
  from .utils import align_target_labels
label_desc: Use image node_id 1 to create a new BatchIterator object  with example: obj = BatchIterator(batches, processor, include_input, include_target, include_context, is_train, num_batches)