code: def infer_multitask_output(y_train):
      """
      Infer output_dim from targets
      This is for multiple tasks.
  
      Parameters
      ----------
      y_train : np.ndarray
          Training targets
  
      Returns
      -------
      tasks_dims : list
          Number of classes for output
      tasks_labels : list
          List of sorted list of initial classes
      """
  
      if len(y_train.shape) < 2:
          raise ValueError(
              "y_train should be of shape (n_examples, n_tasks)"
              + f"but got {y_train.shape}"
          )
      nb_tasks = y_train.shape[1]
      tasks_dims = []
      tasks_labels = []
      for task_idx in range(nb_tasks):
          try:
              output_dim, train_labels = infer_output_dim(
                  y_train[:, task_idx]
              )
              tasks_dims.append(output_dim)
              tasks_labels.append(train_labels)
          except ValueError as err:
              raise ValueError(f"""Error for task {task_idx} : {err}""")
      return tasks_dims, tasks_labels
  
imports: from collections.abc import Sequence
  from itertools import chain
  from scipy.sparse import issparse
  from scipy.sparse.base import spmatrix
  from scipy.sparse import dok_matrix
  from scipy.sparse import lil_matrix
  import scipy.sparse
  import numpy
  import pandas
label_desc: Use image node_id 13 for calling a global function with example usage: infer_multitask_output(y_train) and returns: tasks_dims,  tasks_labels