code: def test_ray_init_existing_instance_via_blocked_ray_start():
      blocked = subprocess.Popen(
          ["ray", "start", "--head", "--block", "--num-cpus", "1999"]
      )
  
      def _connect_to_existing_instance():
          while True:
              try:
                  # Make sure ray.init can connect to the existing cluster.
                  ray.init()
                  if ray.cluster_resources().get("CPU", 0) == 1999:
                      return True
                  else:
                      return False
              except Exception:
                  return False
              finally:
                  ray.shutdown()
  
      try:
          wait_for_condition(
              _connect_to_existing_instance,
              timeout=30,
              retry_interval_ms=1000,
          )
      finally:
          blocked.terminate()
          blocked.wait()
          subprocess.check_output("ray stop --force", shell=True)
  
imports: import os
  import sys
  import unittest.mock
  import signal
  import subprocess
  import grpc
  import pytest
  import ray
  import ray._private.services
  from ray.client_builder import ClientContext
  from ray.cluster_utils import Cluster
  from ray.util.client.common import ClientObjectRef
  from ray.util.client.ray_client_helpers import ray_start_client_server
  from ray.util.client.worker import Worker
  from ray._private.test_utils import wait_for_condition, enable_external_redis
label_desc: Use image node_id 4 for calling a global function with example usage: test_ray_init_existing_instance_via_blocked_ray_start() and returns: True, False, False