class_docstr: Dataset iterator for learning models, e. g. neural networks.
  
  Args:
      data: list of (x, y) pairs for every data type in ``'train'``, ``'valid'`` and ``'test'``
      seed: random seed for data shuffling
      shuffle: whether to shuffle data during batching
  
  Attributes:
      shuffle: whether to shuffle data during batching
      random: instance of ``Random`` initialized with a seed
docstr: Generate batches of inputs and expected output to train neural networks
  
  Args:
      batch_size: number of samples in batch
      data_type: can be either 'train', 'test', or 'valid'
      shuffle: whether to shuffle dataset before batching
  
  Yields:
       a tuple of a batch of inputs and a batch of expected outputs
docstr_tok: ["Generate","batches","of","inputs","and","expected","output","to","train","neural","networks","Args",":","batch_size",":","number","of","samples","in","batch","data_type",":","can","be","either","'train","'",",","'test","'",",","or","'valid'","shuffle",":","whether","to","shuffle","dataset","before","batching","Yields",":","a","tuple","of","a","batch","of","inputs","and","a","batch","of","expected","outputs"]
code: def gen_batches(
      self,
      batch_size: int,
      data_type: str = "train",
      shuffle: bool = None,
  ) -> Iterator[Tuple[tuple, tuple]]:
      """Generate batches of inputs and expected output to train neural networks
  
      Args:
          batch_size: number of samples in batch
          data_type: can be either 'train', 'test', or 'valid'
          shuffle: whether to shuffle dataset before batching
  
      Yields:
           a tuple of a batch of inputs and a batch of expected outputs
      """
      if shuffle is None:
          shuffle = self.shuffle
  
      data = self.data[data_type]
      data_len = len(data)
  
      if data_len == 0:
          return
  
      order = list(range(data_len))
      if shuffle:
          self.random.shuffle(order)
  
      if batch_size < 0:
          batch_size = data_len
  
      for i in range((data_len - 1) // batch_size + 1):
          yield tuple(
              zip(
                  *[
                      data[o]
                      for o in order[
                          i * batch_size : (i + 1) * batch_size
                      ]
                  ]
              )
          )
  
file_path: DeepPavlov/deeppavlov/core/data/data_learning_iterator.py
imports: from random import Random
  from typing import List, Dict, Tuple, Any, Iterator
  from deeppavlov.core.common.registry import register
label_desc: Use image node_id 4 for calling the DataLearningIterator obj's underlying member method code with example usage: obj.gen_batches(batch_size, data_type, shuffle) without return types