code: def calculate_overall_stats(
      output_features, predictions, dataset, training_set_metadata
  ):
      overall_stats = {}
      for of_name, output_feature in output_features.items():
          feature_metadata = training_set_metadata[
              output_feature.feature_name
          ]
          feature_metadata.update(
              training_set_metadata[output_feature.feature_name]
          )
  
          feature_df = predictions.loc[
              :, predictions.columns.str.startswith(of_name)
          ]
          feature_df = feature_df.rename(
              columns=lambda c: c[len(of_name) + 1 :]
          )
  
          target = dataset.loc[:, output_feature.proc_column]
  
          if not isinstance(feature_df, pd.DataFrame):
              logger.warning(
                  "Full computation of stats only supported for pandas dataframes. "
                  "Sampling the first 10000 rows of the feature and target dataframes for computing overall stats."
              )
              feature_df = feature_df.head(
                  n=STATS_SAMPLE_SIZE, npartitions=-1, compute=True
              )
              target = target.head(
                  n=STATS_SAMPLE_SIZE, npartitions=-1, compute=True
              )
  
          overall_stats[
              of_name
          ] = output_feature.calculate_overall_stats(
              feature_df,  # predictions
              target,
              feature_metadata,  # output feature metadata
          )
      return overall_stats
  
imports: import logging
  import os
  import sys
  from abc import ABC, abstractmethod
  from collections import defaultdict, OrderedDict
  from pprint import pformat
  from typing import Dict, List, Optional, Type
  import numpy
  import pandas
  import psutil
  import torch
  from torch import nn
  from ludwig.constants import COMBINED, LAST_HIDDEN, LOGITS, MODEL_ECD, MODEL_GBM, MODEL_LLM
  from ludwig.data.dataset.base import Dataset
  from ludwig.data.utils import convert_to_dict
  from ludwig.distributed.base import DistributedStrategy, LocalStrategy
  from ludwig.globals import is_progressbar_disabled, PREDICTIONS_PARQUET_FILE_NAME, TEST_STATISTICS_FILE_NAME
  from ludwig.models.base import BaseModel
  from ludwig.progress_bar import LudwigProgressBar
  from ludwig.utils.data_utils import save_csv, save_json
  from ludwig.utils.dataframe_utils import from_numpy_dataset
  from ludwig.utils.print_utils import repr_ordered_dict
  from ludwig.utils.registry import Registry
  from ludwig.utils.strings_utils import make_safe_filename
  from ludwig.utils.torch_utils import get_torch_device
label_desc: Use image node_id 3 for calling a global function with example usage: calculate_overall_stats(output_features, predictions, dataset, training_set_metadata) and returns: overall_stats