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 __next__(self):
      if (
          self.n_batches is not None
          and self.batch_count > self.n_batches
      ):
          raise StopIteration
      x, y = (), ()
      while len(x) < self.batch_size or len(y) < self.batch_size:
          try:
              xx, yy = next(self.gen)
              x += xx
              y += yy
          except StopIteration:
              x_nones = tuple([None for _ in range(self.batch_size)])
              y_nones = x_nones
              return x_nones, y_nones
  
      self.batch_count += 1
      if self.batch_count == self.n_batches:
          x = x[: self.size_of_last_batch]
          y = y[: self.size_of_last_batch]
      return x, y
  
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 3 for calling the SingleTaskBatchGenerator obj's underlying member method code with example usage: obj.__next__() and returns: x,  y, x_nones,  y_nones