code: def test_delete_actor_on_disconnect(ray_start_cluster):
      cluster = ray_start_cluster
      with ray_start_cluster_client_server_pair(
          cluster.address
      ) as pair:
          ray, server = pair
  
          @ray.remote
          class Accumulator:
              def __init__(self):
                  self.acc = 0
  
              def inc(self):
                  self.acc += 1
  
              def get(self):
                  return self.acc
  
          actor = Accumulator.remote()
          actor.inc.remote()
  
          assert server_actor_ref_count(server, 1)()
  
          assert ray.get(actor.get.remote()) == 1
  
          ray.close()
  
          wait_for_condition(
              server_actor_ref_count(server, 0), timeout=5
          )
  
          def test_cond():
              alive_actors = [
                  v
                  for v in real_ray._private.state.actors().values()
                  if v["State"] != "DEAD"
              ]
              return len(alive_actors) == 0
  
          # Connect to the real ray again, since we disconnected
          # upon num_clients = 0.
          real_ray.init(
              address=cluster.address,
              namespace="default_test_namespace",
          )
  
          wait_for_condition(test_cond, timeout=10)
  
file_path: ray/python/ray/tests/test_client_references.py
imports: from concurrent.futures import Future
  import pytest
  import ray
  from ray._private.test_utils import object_memory_usage, wait_for_condition
  from ray._raylet import ActorID, ObjectRef
  from ray.util.client import _ClientContext
  from ray.util.client.common import ClientActorRef, ClientObjectRef
  from ray.util.client.ray_client_helpers import ray_start_client_server, ray_start_client_server_pair, ray_start_cluster_client_server_pair
label_desc: Use image node_id 7 for calling a global function with example usage: test_delete_actor_on_disconnect(ray_start_cluster) and returns: unknown, self