code: def test_wait_for_nodes(ray_start_cluster_head):
      """Unit test for `Cluster.wait_for_nodes`.
  
      Adds 4 workers, waits, then removes 4 workers, waits,
      then adds 1 worker, waits, and removes 1 worker, waits.
      """
      cluster = ray_start_cluster_head
      workers = [cluster.add_node() for i in range(4)]
      cluster.wait_for_nodes()
      [cluster.remove_node(w) for w in workers]
      cluster.wait_for_nodes()
  
      assert ray.cluster_resources()["CPU"] == 1
      worker2 = cluster.add_node()
      cluster.wait_for_nodes()
      cluster.remove_node(worker2)
      cluster.wait_for_nodes()
      assert ray.cluster_resources()["CPU"] == 1
  
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 8 for calling a global function with example usage: test_wait_for_nodes(ray_start_cluster_head) without return types