code: def groups_by_state(info: RayContext) -> Dict:
      res = raw_metrics(info)
      info = defaultdict(int)
      if "ray_placement_groups" in res:
          for sample in res["ray_placement_groups"]:
              info[sample.labels["State"]] += sample.value
      for k, v in info.copy().items():
          if v == 0:
              del info[k]
      print(f"Groups by state: {info}")
      return info
  
file_path: ray/python/ray/tests/test_placement_group_metrics.py
imports: from collections import defaultdict
  import pytest
  from typing import Dict
  import ray
  from ray._private.test_utils import raw_metrics, wait_for_condition
  from ray._private.worker import RayContext
  from ray.util.placement_group import remove_placement_group
label_desc: Use image node_id 1 for calling a global function with example usage: groups_by_state(info) and returns: info