code: def test_many_actors(num_actors: int):
      if num_actors == 0:
          logger.info("Skipping test with no actors")
          return
  
      @ray.remote
      class TestActor:
          def running(self):
              return True
  
          def exit(self):
              ray.actor.exit_actor()
  
      actor_class_name = TestActor.__ray_metadata__.class_name
  
      invoke_state_api(
          lambda res: len(res) == 0,
          list_actors,
          filters=[
              ("state", "=", "ALIVE"),
              ("class_name", "=", actor_class_name),
          ],
          key_suffix="0",
          limit=STATE_LIST_LIMIT,
      )
  
      actors = [
          TestActor.remote()
          for _ in tqdm.trange(num_actors, desc="Launching actors...")
      ]
  
      waiting_actors = [actor.running.remote() for actor in actors]
      logger.info("Waiting for actors to finish...")
      ray.get(waiting_actors)
  
      invoke_state_api_n(
          lambda res: len(res) == num_actors,
          list_actors,
          filters=[
              ("state", "=", "ALIVE"),
              ("class_name", "=", actor_class_name),
          ],
          key_suffix=f"{num_actors}",
          limit=STATE_LIST_LIMIT,
      )
  
      exiting_actors = [actor.exit.remote() for actor in actors]
      for _ in tqdm.trange(len(actors), desc="Destroying actors..."):
          _exitted, exiting_actors = ray.wait(exiting_actors)
  
      invoke_state_api(
          lambda res: len(res) == 0,
          list_actors,
          filters=[
              ("state", "=", "ALIVE"),
              ("class_name", "=", actor_class_name),
          ],
          key_suffix="0",
          limit=STATE_LIST_LIMIT,
      )
  
imports: import click
  import json
  import ray
  from ray._private.ray_constants import LOG_PREFIX_ACTOR_NAME, LOG_PREFIX_JOB_ID
  from ray._private.state_api_test_utils import STATE_LIST_LIMIT, StateAPIMetric, aggregate_perf_results, invoke_state_api, GLOBAL_STATE_STATS
  import ray._private.test_utils
  import tqdm
  import time
  import os
  from ray.util.placement_group import placement_group, remove_placement_group
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  from ray.util.state import get_log, list_actors, list_objects, list_tasks
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: test_many_actors(num_actors) and returns: True