class_docstr: Dataset iterator for fitting estimator models, like vocabs, kNN, vectorizers.
  Data is passed as a list of strings(documents).
  Generate batches (for large datasets).
  
  Args:
      data: list of documents
      doc_ids: provided document ids
      seed: random seed for data shuffling
      shuffle: whether to shuffle data during batching
  
  Attributes:
      shuffle: whether to shuffle data during batching
      random: instance of :class:`Random` initialized with a seed
      data: list of documents
      doc_ids: provided by a user ids or generated automatically ids
docstr: Gen batches of documents.
  
  Args:
      batch_size: a number of samples in a single batch
      shuffle: whether to shuffle data during batching
  
  Yields:
      generated tuple of documents and their ids
docstr_tok: ["Gen","batches","of","documents",".","Args",":","batch_size",":","a","number","of","samples","in","a","single","batch","shuffle",":","whether","to","shuffle","data","during","batching","Yields",":","generated","tuple","of","documents","and","their","ids"]
code: def gen_batches(
      self, batch_size: int, shuffle: bool = None
  ) -> Generator[Tuple[List[str], List[int]], Any, None]:
      """Gen batches of documents.
  
      Args:
          batch_size: a number of samples in a single batch
          shuffle: whether to shuffle data during batching
  
      Yields:
          generated tuple of documents and their ids
  
      """
      if shuffle is None:
          shuffle = self.shuffle
  
      if shuffle:
          _doc_ids = self.random.sample(self.doc_ids, len(self.doc_ids))
      else:
          _doc_ids = self.doc_ids
  
      if batch_size > 0:
          batches = [
              _doc_ids[i : i + batch_size]
              for i in range(0, len(_doc_ids), batch_size)
          ]
      else:
          batches = [_doc_ids]
  
      # DEBUG
      # len_batches = len(batches)
  
      for i, doc_ids in enumerate(batches):
          # DEBUG
          # logger.info(
          #     "Processing batch # {} of {} ({} documents)".format(i, len_batches, len(doc_index)))
          docs = [self.get_doc_content(doc_id) for doc_id in doc_ids]
          yield docs, doc_ids
  
file_path: DeepPavlov/deeppavlov/core/data/data_fitting_iterator.py
imports: from logging import getLogger
  from random import Random
  from typing import List, Generator, Tuple, Any, Optional
  from deeppavlov.core.common.registry import register
label_desc: Use image node_id 4 for calling the DataFittingIterator obj's underlying member method code with example usage: obj.gen_batches(batch_size, shuffle) without return types