code: def test_load_balancing(ray_start_cluster):
      # This test ensures that tasks are being assigned to all raylets
      # in a roughly equal manner.
      cluster = ray_start_cluster
      num_nodes = 3
      num_cpus = 7
      for _ in range(num_nodes):
          cluster.add_node(num_cpus=num_cpus)
      ray.init(address=cluster.address)
  
      @ray.remote
      def f():
          time.sleep(0.10)
          return ray._private.worker.global_worker.node.unique_id
  
      attempt_to_load_balance(f, [], 100, num_nodes, 10)
      attempt_to_load_balance(f, [], 1000, num_nodes, 100)
  
imports: import collections
  import logging
  import platform
  import subprocess
  import sys
  import time
  import unittest
  import numpy
  import pytest
  import ray
  import ray.cluster_utils
  import ray.util.accelerators
  from ray._private.internal_api import memory_summary
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  from ray._private.test_utils import Semaphore, SignalActor, object_memory_usage, get_metric_check_condition, wait_for_condition, MetricSamplePattern
label_desc: Use image node_id 2 for calling a global function with example usage: test_load_balancing(ray_start_cluster) and returns: ray