code: def _extract_stats(stats: Dict, key: str) -> Dict[str, Any]:
      if key in stats:
          return stats[key]
  
      multiagent_stats = {}
      for k, v in stats.items():
          if isinstance(v, dict):
              if key in v:
                  multiagent_stats[k] = v[key]
  
      return multiagent_stats
  
file_path: ray/python/ray/rllib/evaluation/metrics.py
imports: import collections
  import logging
  import numpy
  from typing import Any, Dict, List, Optional, TYPE_CHECKING
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.metrics.learner_info import LEARNER_STATS_KEY
  from ray.rllib.utils.typing import GradInfoDict, LearnerStatsDict, ResultDict
label_desc: Use image node_id 1 for calling a global function with example usage: _extract_stats(stats, key) and returns: multiagent_stats, stats