code: def test_heartbeats_single(ray_start_cluster_head):
      """Unit test for `Cluster.wait_for_nodes`.
  
      Test proper metrics.
      """
      cluster = ray_start_cluster_head
      monitor = setup_monitor(cluster.gcs_address)
      total_cpus = ray._private.state.cluster_resources()["CPU"]
      verify_load_metrics(monitor, ({"CPU": 0.0}, {"CPU": total_cpus}))
  
      @ray.remote
      def work(signal):
          wait_signal = signal.wait.remote()
          while True:
              ready, not_ready = ray.wait([wait_signal], timeout=0)
              if len(ready) == 1:
                  break
              time.sleep(1)
  
      signal = SignalActor.remote()
  
      work_handle = work.remote(signal)
      verify_load_metrics(monitor, ({"CPU": 1.0}, {"CPU": total_cpus}))
  
      ray.get(signal.send.remote())
      ray.get(work_handle)
  
      @ray.remote(num_cpus=1)
      class Actor:
          def work(self, signal):
              wait_signal = signal.wait.remote()
              while True:
                  ready, not_ready = ray.wait([wait_signal], timeout=0)
                  if len(ready) == 1:
                      break
                  time.sleep(1)
  
      signal = SignalActor.remote()
  
      test_actor = Actor.remote()
      work_handle = test_actor.work.remote(signal)
      time.sleep(
          1
      )  # Time for actor to get placed and the method to start.
  
      verify_load_metrics(monitor, ({"CPU": 1.0}, {"CPU": total_cpus}))
  
      ray.get(signal.send.remote())
      ray.get(work_handle)
      del monitor
  
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 7 for calling a global function with example usage: test_heartbeats_single(ray_start_cluster_head) without return types