class_docstr: Class merges data from several dataset iterators. When used for batch generation batches from
  merged dataset iterators are united into one batch. If sizes of merged datasets are different
  smaller datasets are repeated until their size becomes equal to the largest dataset.
  
  Args:
      data: dictionary which keys are task names and values are dictionaries with fields
          ``"train", "valid", "test"``.
      num_train_epochs: number of training epochs
      tasks: dictionary which keys are task names and values are init params of dataset iterators. If task has
          key-value pair ``'use_task_defaults': False`` task_defaults for this task dataset iterator will be ignored.
      batch_size: batch_size
      sampling_mode: mode of sampling we use. It can be plain, uniform or anneal.
      gradient_accumulation_steps: number of gradient accumulation steps. Default is 1
      steps_per_epoch: number of steps per epoch. Nesessary if gradient_accumulation_steps > 1
      iterator_class_name: name of iterator class.
      use_label_name, seed, features - parameters for the iterator class
      one_element_tuples: if True, tuple of x consisting of one element is returned in this element. Default: True
      task_defaults: default task parameters.
      seed - random seed for sampling
  
  Attributes:
      data: dictionary of data with fields "train", "valid" and "test" (or some of them)
class_docstr_tok: ["Class","merges","data","from","several","dataset","iterators",".","When","used","for","batch","generation","batches","from","merged","dataset","iterators","are","united","into","one","batch",".","If","sizes","of","merged","datasets","are","different","smaller","datasets","are","repeated","until","their","size","becomes","equal","to","the","largest","dataset",".","Args",":","data",":","dictionary","which","keys","are","task","names","and","values","are","dictionaries","with","fields","``","``","train","''",",","``","valid","''",",","``","test","''","``",".","num_train_epochs",":","number","of","training","epochs","tasks",":","dictionary","which","keys","are","task","names","and","values","are","init","params","of","dataset","iterators",".","If","task","has","key-value","pair","``","'use_task_defaults","'",":","False","``","task_defaults","for","this","task","dataset","iterator","will","be","ignored",".","batch_size",":","batch_size","sampling_mode",":","mode","of","sampling","we","use",".","It","can","be","plain",",","uniform","or","anneal",".","gradient_accumulation_steps",":","number","of","gradient","accumulation","steps",".","Default","is","1","steps_per_epoch",":","number","of","steps","per","epoch",".","Nesessary","if","gradient_accumulation_steps",">","1","iterator_class_name",":","name","of","iterator","class",".","use_label_name",",","seed",",","features","-","parameters","for","the","iterator","class","one_element_tuples",":","if","True",",","tuple","of","x","consisting","of","one","element","is","returned","in","this","element",".","Default",":","True","task_defaults",":","default","task","parameters",".","seed","-","random","seed","for","sampling","Attributes",":","data",":","dictionary","of","data","with","fields","``","train","''",",","``","valid","''","and","``","test","''","(","or","some","of","them",")"]
docstr: Function that transforms data from dataset before yielding
docstr_tok: ["Function","that","transforms","data","from","dataset","before","yielding"]
code: def _transform_before_yielding(self, x, y, batch_size):
      """Function that transforms data from dataset before yielding"""
  
      if len(x) != len(y):
          raise Exception(f"x has len {len(x)} but y has len {len(y)}")
      new_x, new_y = [], []
      for i in range(batch_size):
          x_tuple = tuple([x[t_id][i] for t_id in range(self.n_tasks)])
          y_tuple = tuple([y[t_id][i] for t_id in range(self.n_tasks)])
          if self.n_tasks == 1:
              x_tuple = x_tuple[0]
              y_tuple = y_tuple[0]
          new_x.append(x_tuple)
          new_y.append(y_tuple)
      batches = (tuple(new_x), tuple(new_y))
      return batches
  
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 5 for calling the MultiTaskIterator obj's underlying member method code with example usage: obj._transform_before_yielding(x, y, batch_size) and returns: batches