docstr: Sums up the estimated number of tokens.
docstr_tok: ["Sums","up","the","estimated","number","of","tokens","."]
code: def aggregate(self) -> Dict[str, ModelCost]:
      """Sums up the estimated number of tokens."""
      models_to_costs: Dict[str, ModelCost] = defaultdict(ModelCost)
  
      for run_dir in os.listdir(self._run_suite_path):
          run_path: str = os.path.join(self._run_suite_path, run_dir)
  
          if not os.path.isdir(run_path):
              continue
  
          run_spec_path: str = os.path.join(run_path, "run_spec.json")
          if not os.path.isfile(run_spec_path):
              continue
  
          # Extract the model name
          with open(run_spec_path) as f:
              run_spec = json.load(f)
              model: str = run_spec["adapter_spec"]["model"]
  
          metrics_path: str = os.path.join(run_path, "stats.json")
          with open(metrics_path) as f:
              metrics = json.load(f)
  
              for metric in metrics:
                  cost: ModelCost = models_to_costs[model]
                  metric_name: str = metric["name"]["name"]
                  if metric_name == "num_prompt_tokens":
                      cost.add_prompt_tokens(metric["sum"])
                  elif metric_name == "max_num_completion_tokens":
                      cost.add_num_completion_tokens(metric["sum"])
  
      return models_to_costs
  
file_path: H2O/h2o_hf/helm/scripts/estimate_cost.py
imports: import argparse
  import json
  import os
  from collections import defaultdict
  from dataclasses import dataclass
  from typing import Dict
label_desc: Use image node_id 2 for calling the CostCalculator obj's underlying member method code with example usage: obj.aggregate() and returns: models_to_costs