code: def test_detached_actor_autoscaling(ray_start_cluster_head):
      """Make sure that a detached actor, which belongs to a dead job, can start
      workers on nodes that were added after the job ended.
      """
      cluster = ray_start_cluster_head
      cluster.add_node(num_cpus=2)
      cluster.wait_for_nodes(2)
  
      @ray.remote(num_cpus=1)
      class Actor:
          def __init__(self):
              self.handles = []
  
          def start_actors(self, n):
              self.handles.extend([Actor.remote() for _ in range(n)])
  
          def get_children(self):
              return self.handles
  
          def ping(self):
              pass
  
      main_actor = Actor.options(
          lifetime="detached", name="main"
      ).remote()
      ray.get(main_actor.ping.remote())
  
      ray.shutdown()
      ray.init(
          address=cluster.address, namespace="default_test_namespace"
      )
  
      main_actor = ray.get_actor("main")
      num_to_start = int(ray.available_resources().get("CPU", 0) + 1)
      print(f"Starting {num_to_start} actors")
      ray.get(main_actor.start_actors.remote(num_to_start))
  
      actor_handles = ray.get(main_actor.get_children.remote())
  
      up, down = ray.wait(
          [actor.ping.remote() for actor in actor_handles],
          timeout=5,
          num_returns=len(actor_handles),
      )
      assert len(up) == len(actor_handles) - 1
      assert len(down) == 1
  
      cluster.add_node(num_cpus=1)
      cluster.wait_for_nodes(3)
      up, down = ray.wait(
          [actor.ping.remote() for actor in actor_handles],
          timeout=5,
          num_returns=len(actor_handles),
      )
      assert len(up) == len(actor_handles)
      assert len(down) == 0
  
file_path: ray/python/ray/tests/test_multi_node_2.py
imports: import logging
  import time
  import pytest
  import ray
  from ray._private.test_utils import SignalActor, generate_system_config_map, wait_for_condition
  from ray.autoscaler._private.monitor import Monitor
  from ray.autoscaler.sdk import request_resources
  from ray.cluster_utils import Cluster
  from ray.util.placement_group import placement_group, remove_placement_group
label_desc: Use image node_id 10 for calling a global function with example usage: test_detached_actor_autoscaling(ray_start_cluster_head) and returns: self