class_docstr: Takes care of collecting, sampling, serializing, and publishing a set of metrics.
class_docstr_tok: ["Takes","care","of","collecting",",","sampling",",","serializing",",","and","publishing","a","set","of","metrics","."]
docstr: Return a dict of metrics.
docstr_tok: ["Return","a","dict","of","metrics","."]
code: def aggregate(self) -> dict:
      """Return a dict of metrics."""
      aggregated_metrics = {}
      for metric in self.metrics:
          try:
              serialized_metric = metric.aggregate()
              aggregated_metrics.update(serialized_metric)
              # aggregated_metrics = wandb.util.merge_dicts(
              #     aggregated_metrics, metric.serialize()
              # )
          except Exception as e:
              logger.error(f"Failed to serialize metric: {e}")
      return aggregated_metrics
  
imports: import datetime
  import logging
  import sys
  import threading
  from typing import TYPE_CHECKING, Any, List, Optional, TypeVar
  import psutil
label_desc: Use image node_id 3 for calling the MetricsMonitor obj's underlying member method code with example usage: obj.aggregate() and returns: aggregated_metrics