class_docstr: Iterates over data for Morphological Tagging.
  A subclass of :class:`~deeppavlov.core.data.data_learning_iterator.DataLearningIterator`.
  
  Args:
      seed: random seed for data shuffling
      shuffle: whether to shuffle data during batching
      validation_split: the fraction of validation data
          (is used only if there is no `valid` subset in `data`)
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
      return_indexes: whether to return indexes of batch elements in initial dataset
  Yields:
      a tuple of a batch of inputs and a batch of expected outputs.
      If `return_indexes` is True, also yields indexes of batch elements.
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","return_indexes",":","whether","to","return","indexes","of","batch","elements","in","initial","dataset","Yields",":","a","tuple","of","a","batch","of","inputs","and","a","batch","of","expected","outputs",".","If","`","return_indexes","`","is","True",",","also","yields","indexes","of","batch","elements","."]
code: def gen_batches(
      self,
      batch_size: int,
      data_type: str = "train",
      shuffle: bool = None,
      return_indexes: bool = False,
  ) -> Iterator[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
          return_indexes: whether to return indexes of batch elements in initial dataset
      Yields:
          a tuple of a batch of inputs and a batch of expected outputs.
          If `return_indexes` is True, also yields indexes of batch elements.
      """
      if shuffle is None:
          shuffle = self.shuffle
      data = self.data[data_type]
      lengths = [len(x[0]) for x in data]
      indexes = np.argsort(lengths)
      L = len(data)
      if batch_size < 0:
          batch_size = L
      starts = list(range(0, L, batch_size))
      if shuffle:
          self.random.shuffle(starts)
      for start in starts:
          indexes_to_yield = indexes[start : start + batch_size]
          data_to_yield = tuple(
              list(x)
              for x in zip(*([data[i] for i in indexes_to_yield]))
          )
          if return_indexes:
              yield indexes_to_yield, data_to_yield
          else:
              yield data_to_yield
  
file_path: DeepPavlov/deeppavlov/dataset_iterators/morphotagger_iterator.py
imports: from typing import Tuple, List, Dict, Any, Iterator
  import numpy
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.data_learning_iterator import DataLearningIterator
label_desc: Use image node_id 3 for calling the MorphoTaggerDatasetIterator obj's underlying member method code with example usage: obj.gen_batches(batch_size, data_type, shuffle, return_indexes) without return types