code: def average_scores(scores, simple_model_scores, include_classes):
      """
      Calculate the average of the scores for each metric for all classes.
  
      Parameters
      ----------
      scores : pd.DataFrame
          the scores for the given model
      simple_model_scores : pd.DataFrame
          the scores for the simple model
      include_classes : List[Hashable]
          the classes to include in the calculation
  
      Returns
      -------
      Dictionary[str, Dictionary[str, float]]
          the average scores for each metric. The keys are the metric names, and the values are a dictionary
          with the keys being Origin and Simple and the values being the average score.
      """
      result = {}
      metrics = scores["Metric"].unique()
      for metric in metrics:
          model_score = 0
          simple_score = 0
          total = 0
          for _, row in scores.loc[
              scores["Metric"] == metric
          ].iterrows():
              if (
                  include_classes
                  and row["Class"] not in include_classes
              ):
                  continue
              model_score += row["Value"]
              simple_score += simple_model_scores.loc[
                  (simple_model_scores["Class"] == row["Class"])
                  & (simple_model_scores["Metric"] == metric)
              ]["Value"].values[0]
              total += 1
  
          result[metric] = {
              "Origin": model_score / total,
              "Simple": simple_score / total,
          }
  
      return result
  
imports: from typing import Any, Callable, Dict, Hashable, List, Optional, Union
  import numpy
  import pandas
  import plotly.express
  from deepchecks.core import CheckResult, ConditionCategory, ConditionResult, DatasetKind
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.utils import plot
  from deepchecks.utils.metrics import get_gain
  from deepchecks.utils.strings import format_percent
  from deepchecks.vision._shared_docs import docstrings
  from deepchecks.vision.base_checks import TrainTestCheck
  from deepchecks.vision.context import Context
  from deepchecks.vision.metrics_utils import CustomClassificationScorer, get_scorers_dict, metric_results_to_df
  from deepchecks.vision.metrics_utils.scorers import filter_classes_for_display
  from deepchecks.vision.vision_data import TaskType, VisionData
  from deepchecks.vision.vision_data.batch_wrapper import BatchWrapper
label_desc: Use image node_id 2 for calling a global function with example usage: average_scores(scores, simple_model_scores, include_classes) and returns: result