code: def merge_stat(stats: Dict[MetricName, Stat], stat: Stat):
      """Mutate the appropriate part of `stats`."""
      if stat.name not in stats:
          # Important: copy so that we don't mutate accidentally
          stats[stat.name] = replace(stat)
      else:
          stats[stat.name].merge(stat)
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/metrics/statistic.py
imports: from dataclasses import dataclass, replace
  import math
  from typing import Dict, Optional
  from .metric_name import MetricName
label_desc: Use image node_id 1 for calling a global function with example usage: merge_stat(stats, stat) without return types