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
Function that transforms data from dataset before yielding
deeppavlov/dataset_iterators/multitask_iterator.py