class_docstr: Batch generator for a single task.
  If there are no elements in the dataset to form another batch, Nones are returned.
  Args:
      dataset_iterator: dataset iterator from which batches are drawn.
      batch_size: size fo the batch.
      data_type: "train", "valid", or "test"
      shuffle: whether dataset will be shuffled.
      n_batches: the number of batches that will be generated.
class_docstr_tok: ["Batch","generator","for","a","single","task",".","If","there","are","no","elements","in","the","dataset","to","form","another","batch",",","Nones","are","returned",".","Args",":","dataset_iterator",":","dataset","iterator","from","which","batches","are","drawn",".","batch_size",":","size","fo","the","batch",".","data_type",":","``","train","''",",","``","valid","''",",","or","``","test","''","shuffle",":","whether","dataset","will","be","shuffled",".","n_batches",":","the","number","of","batches","that","will","be","generated","."]
code: def __init__(
      self,
      dataset_iterator: Union[DataLearningIterator],
      batch_size: int,
      data_type: str,
      shuffle: bool,
      n_batches: Optional[int] = None,
      size_of_last_batch: Optional[int] = None,
  ):
      self.dataset_iterator = dataset_iterator
      self.batch_size = batch_size
      self.data_type = data_type
      self.shuffle = shuffle
      self.n_batches = n_batches
      self.size_of_last_batch = (
          self.batch_size
          if size_of_last_batch is None
          else size_of_last_batch
      )
  
      self.inner_batch_size = math.gcd(
          len(self.dataset_iterator.data[data_type]), batch_size
      )
      self.gen = self.dataset_iterator.gen_batches(
          self.inner_batch_size, self.data_type, self.shuffle
      )
      self.batch_count = 0
  
imports: import copy
  import math
  import random
  from logging import getLogger
  from typing import Iterator, Optional, Tuple, Union
  import numpy
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.core.common.params import from_params
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.data_learning_iterator import DataLearningIterator
label_desc: Use image node_id 1 to create a new SingleTaskBatchGenerator object  with example: obj = SingleTaskBatchGenerator(dataset_iterator, batch_size, data_type, shuffle, n_batches, size_of_last_batch)