code: def metric_results_to_df(
      results: dict, dataset: VisionData
  ) -> pd.DataFrame:
      """Get dict of metric name to tensor of classes scores, and convert it to dataframe."""
      result_list = []
      for metric, scores in results.items():
          if isinstance(scores, Number):
              result_list.append([metric, pd.NA, pd.NA, scores])
          elif len(scores) == 1:
              result_list.append([metric, pd.NA, pd.NA, scores[0]])
          elif isinstance(
              scores, (torch.Tensor, list, np.ndarray, dict)
          ):
              # Deepchecks scorers returns classification class scores as dict but object detection as array TODO: unify
              scores_iterator = (
                  scores.items()
                  if isinstance(scores, dict)
                  else enumerate(scores)
              )
              for class_id, class_score in scores_iterator:
                  class_name = dataset.label_map[class_id]
                  # The data might contain fewer classes than the model was trained on. filtering out
                  # any class id which is not presented in the data.
                  if (
                      np.isnan(class_score)
                      or class_name
                      not in dataset.get_observed_classes()
                      or class_score == -1
                  ):
                      continue
                  result_list.append(
                      [metric, class_id, class_name, class_score]
                  )
          else:
              raise DeepchecksValueError(
                  f"The metric {metric} returned a "
                  f"{type(scores)} instead of an array/tensor"
              )
  
      return pd.DataFrame(
          result_list,
          columns=["Metric", "Class", "Class Name", "Value"],
      )
  
file_path: deepchecks/deepchecks/vision/metrics_utils/scorers.py
imports: import typing
  from copy import copy
  from numbers import Number
  import numpy
  import pandas
  import torch
  from ignite.metrics import Metric
  from deepchecks.core import DatasetKind
  from deepchecks.core.errors import DeepchecksNotSupportedError, DeepchecksValueError
  from deepchecks.utils.metrics import get_scorer_name
  from deepchecks.vision.metrics_utils import CustomClassificationScorer, CustomMetric, ObjectDetectionAveragePrecision, ObjectDetectionTpFpFn
  from deepchecks.vision.metrics_utils.semantic_segmentation_metrics import MeanDice, MeanIoU
  from deepchecks.vision.vision_data import TaskType, VisionData
label_desc: Use image node_id 5 for calling a global function with example usage: metric_results_to_df(results, dataset) and returns: pd