code: def test_detached_actor_restarts(
      ray_start_regular_with_external_redis,
  ):
      # Detached actors are owned by GCS. This test is to ensure detached actors
      # can restart even GCS restarts.
  
      @ray.remote
      class A:
          def ready(self):
              import os
  
              return os.getpid()
  
      a = A.options(
          name="a", lifetime="detached", max_restarts=-1
      ).remote()
  
      pid = ray.get(a.ready.remote())
      ray._private.worker._global_node.kill_gcs_server()
      p = psutil.Process(pid)
      p.kill()
      ray._private.worker._global_node.start_gcs_server()
  
      while True:
          try:
              assert ray.get(a.ready.remote()) != pid
              break
          except ray.exceptions.RayActorError:
              continue
  
imports: import sys
  import os
  import threading
  from time import sleep
  import pytest
  import ray
  from ray._private.utils import get_or_create_event_loop
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  import ray._private.gcs_utils
  from ray._private import ray_constants
  from ray._private.test_utils import convert_actor_state, enable_external_redis, generate_system_config_map, wait_for_condition, wait_for_pid_to_exit, run_string_as_driver
  from ray.job_submission import JobSubmissionClient, JobStatus
  from ray._raylet import GcsClient
  import psutil
label_desc: Use image node_id 10 for calling a global function with example usage: test_detached_actor_restarts(ray_start_regular_with_external_redis) and returns: os