code: def test_actor_gc(monkeypatch, shutdown_only):
      MAX_DEAD_ACTOR_CNT = 5
      with monkeypatch.context() as m:
          m.setenv(
              "RAY_maximum_gcs_destroyed_actor_cached_count",
              MAX_DEAD_ACTOR_CNT,
          )
          ray.init()
  
          @ray.remote
          class Actor:
              def ready(self):
                  pass
  
          actors = [Actor.remote() for _ in range(10)]
          ray.get([actor.ready.remote() for actor in actors])
          alive_actors = 0
          for a in list_actors():
              if a["state"] == "ALIVE":
                  alive_actors += 1
          assert alive_actors == 10
          # Kill actors
          del actors
  
          def verify_cached_dead_actor_cleaned():
              return len(list_actors()) == MAX_DEAD_ACTOR_CNT  # noqa
  
          wait_for_condition(verify_cached_dead_actor_cleaned)
  
          # Test detached actors
          actors = [
              Actor.options(lifetime="detached").remote()
              for _ in range(10)
          ]
          ray.get([actor.ready.remote() for actor in actors])
          alive_actors = 0
          for a in list_actors():
              if a["state"] == "ALIVE":
                  alive_actors += 1
          assert alive_actors == 10
          # Kill actors
          for actor in actors:
              ray.kill(actor)
  
          wait_for_condition(verify_cached_dead_actor_cleaned)
  
          # Test actors created by a driver.
  
          driver = """
  import ray
  from ray.util.state import list_actors
  ray.init("auto")
  
  @ray.remote
  class A:
      def ready(self):
          pass
  
  actors = [A.remote() for _ in range(10)]
  ray.get([actor.ready.remote() for actor in actors])
  alive_actors = 0
  for a in list_actors():
      if a["state"] == "ALIVE":
          alive_actors += 1
  assert alive_actors == 10
  """
  
          run_string_as_driver(driver)
          # Driver exits, so dead actors must be cleaned.
          wait_for_condition(verify_cached_dead_actor_cleaned)
          print(list_actors())
  
imports: import os
  import sys
  import time
  import numpy
  import pytest
  import ray
  import ray._private.gcs_utils
  from ray.util.state import list_actors
  import ray.cluster_utils
  from ray._private.test_utils import SignalActor, convert_actor_state, kill_actor_and_wait_for_failure, make_global_state_accessor, run_string_as_driver, wait_for_condition, wait_for_pid_to_exit
  from ray._private.ray_constants import gcs_actor_scheduling_enabled
  from ray.experimental.internal_kv import _internal_kv_get, _internal_kv_put
label_desc: Use image node_id 37 for calling a global function with example usage: test_actor_gc(monkeypatch, shutdown_only) and returns: unknown