code: def get_node_to_deployment_to_num_replicas():
      actors = list_actors()
      print(actors)
      # {node_id: {deployment_name: num_replicas}}
      node_to_deployment_to_num_replicas = defaultdict(dict)
      for actor in actors:
          if (
              not any(
                  name in actor["name"]
                  for name in [
                      "app#deploy",
                      "app1#deploy",
                      "app2#deploy",
                  ]
              )
              or actor["state"] != "ALIVE"
          ):
              continue
          deployment_name = None
          if "deploy1" in actor["name"]:
              deployment_name = "deploy1"
          else:
              assert "deploy2" in actor["name"]
              deployment_name = "deploy2"
          node_to_deployment_to_num_replicas[actor["node_id"]][
              deployment_name
          ] = (
              node_to_deployment_to_num_replicas[actor["node_id"]].get(
                  deployment_name, 0
              )
              + 1
          )
  
      return node_to_deployment_to_num_replicas
  
file_path: ray/python/ray/serve/tests/test_max_replicas_per_node.py
imports: import sys
  from collections import defaultdict
  import pytest
  import ray
  from ray import serve
  from ray.util.state import list_actors
label_desc: Use image node_id 1 for calling a global function with example usage: get_node_to_deployment_to_num_replicas() and returns: node_to_deployment_to_num_replicas