code: def summarize_resource_usage(
      path: str, tags: Optional[List[str]] = None
  ) -> List[ResourceUsageSummary]:
      """Create resource usage summaries for each code block/function that was decorated with ResourceUsageTracker.
  
      Each entry of the list corresponds to the metrics collected from a code block/function run.
      Important: code blocks that ran more than once are averaged.
  
      :param path: corresponds to the `output_dir` argument in a ResourceUsageTracker run.
      :param tags: (optional) list of tags to create summary for. If None, metrics from all tags will be summarized.
      """
      summary = dict()
      # metric types: system_resource_usage, torch_ops_resource_usage.
      all_metric_types = {
          "system_resource_usage",
          "torch_ops_resource_usage",
      }
      for metric_type in all_metric_types.intersection(
          os.listdir(path)
      ):
          metric_type_path = os.path.join(path, metric_type)
          # code block tags correspond to the `tag` argument in ResourceUsageTracker.
          for code_block_tag in os.listdir(metric_type_path):
              if tags and code_block_tag not in tags:
                  continue
              if code_block_tag not in summary:
                  summary[code_block_tag] = {}
              run_path = os.path.join(metric_type_path, code_block_tag)
              # Metrics from code blocks/functions that ran more than once are averaged.
              summary[code_block_tag][metric_type] = average_runs(
                  run_path
              )
  
      summary_list = []
      for code_block_tag, metric_type_dicts in summary.items():
          merged_summary: Dict[str, Union[float, int]] = {}
          for metrics in metric_type_dicts.values():
              assert "num_runs" in metrics
              assert (
                  "num_runs" not in merged_summary
                  or metrics["num_runs"] == merged_summary["num_runs"]
              )
              merged_summary.update(metrics)
          summary_list.append(
              ResourceUsageSummary(
                  code_block_tag=code_block_tag,
                  metric_to_values=merged_summary,
                  metric_names=set(merged_summary),
              )
          )
      return summary_list
  
imports: import csv
  import logging
  import os
  from dataclasses import dataclass
  from statistics import mean
  from typing import Dict, List, Optional, Set, Union
  import ludwig.modules.metric_modules
  from ludwig.benchmarking.utils import format_memory, format_time
  from ludwig.globals import MODEL_HYPERPARAMETERS_FILE_NAME
  from ludwig.modules.metric_registry import get_metric_classes, metric_feature_type_registry
  from ludwig.types import ModelConfigDict
  from ludwig.utils.data_utils import load_json
label_desc: Use image node_id 7 for calling a global function with example usage: summarize_resource_usage(path, tags) and returns: summary_list