code: def calculate_scores(
      solution: np.ndarray,
      prediction: np.ndarray,
      task_type: int,
      metrics: Sequence[Scorer],
      *,
      X_data: Optional[SUPPORTED_XDATA_TYPES] = None,
      scoring_functions: Optional[List[Scorer]] = None,
  ) -> Dict[str, float]:
      """
      Returns the scores (a magnitude that allows casting the
      optimization problem as a maximization one) for the
      given Auto-Sklearn Scorer objects.
  
      Parameters
      ----------
      solution: np.ndarray
          The ground truth of the targets
      prediction: np.ndarray
          The best estimate from the model, of the given targets
      task_type: int
          To understand if the problem task is classification
          or regression
      metrics: Sequence[Scorer]
          A list of objects that hosts a function to calculate how good the
          prediction is according to the solution.
      X_data : array-like [n_samples x n_features]
          X data used to obtain the predictions
      scoring_functions: List[Scorer]
          A list of metrics to calculate multiple losses
      Returns
      -------
      Dict[str, float]
      """
      if task_type not in TASK_TYPES:
          raise NotImplementedError(task_type)
  
      _validate_metrics(
          metrics=metrics, scoring_functions=scoring_functions
      )
  
      to_score = list(metrics)
      if scoring_functions:
          to_score.extend(scoring_functions)
  
      score_dict = dict()
      if task_type in REGRESSION_TASKS:
          for metric_ in to_score:
              try:
                  score_dict[metric_.name] = _compute_single_scorer(
                      metric=metric_,
                      prediction=prediction,
                      solution=solution,
                      task_type=task_type,
                      X_data=X_data,
                  )
              except ValueError as e:
                  print(e, e.args[0])
                  if (
                      e.args[0]
                      == "Mean Squared Logarithmic Error cannot be used when "
                      "targets contain negative values."
                  ):
                      continue
                  else:
                      raise e
  
      else:
          for metric_ in to_score:
              # TODO maybe annotate metrics to define which cases they can
              # handle?
  
              try:
                  score_dict[metric_.name] = _compute_single_scorer(
                      metric=metric_,
                      prediction=prediction,
                      solution=solution,
                      task_type=task_type,
                      X_data=X_data,
                  )
              except ValueError as e:
                  if e.args[0] == "multiclass format is not supported":
                      continue
                  elif (
                      e.args[0]
                      == "Samplewise metrics are not available "
                      "outside of multilabel classification."
                  ):
                      continue
                  elif (
                      e.args[0] == "Target is multiclass but "
                      "average='binary'. Please choose another average "
                      "setting, one of [None, 'micro', 'macro', 'weighted']."
                  ):
                      continue
                  else:
                      raise e
  
      return score_dict
  
imports: from abc import ABCMeta, abstractmethod
  from typing import Any, Callable, Dict, List, Optional, Sequence, Union
  import collections
  from functools import partial
  from itertools import product
  import numpy
  import sklearn.metrics
  from sklearn.utils.multiclass import type_of_target
  from smac.utils.constants import MAXINT
  from autosklearn.constants import BINARY_CLASSIFICATION, MULTICLASS_CLASSIFICATION, MULTILABEL_CLASSIFICATION, MULTIOUTPUT_REGRESSION, REGRESSION, REGRESSION_TASKS, TASK_TYPES
  from autosklearn.data.target_validator import SUPPORTED_XDATA_TYPES
  from .util import sanitize_array
label_desc: Use image node_id 3 for calling a global function with example usage: calculate_scores(solution, prediction, task_type, metrics) and returns: score_dict