code: def test_actor_different_numbers_of_gpus(ray_start_cluster):
      # Test that we can create actors on two nodes that have different
      # numbers of GPUs.
      cluster = ray_start_cluster
      cluster.add_node(num_cpus=10, num_gpus=0)
      cluster.add_node(num_cpus=10, num_gpus=5)
      cluster.add_node(num_cpus=10, num_gpus=10)
      ray.init(address=cluster.address)
  
      @ray.remote(num_gpus=1)
      class Actor1:
          def __init__(self):
              self.gpu_ids = ray.get_gpu_ids()
  
          def get_location_and_ids(self):
              return (
                  ray._private.worker.global_worker.node.unique_id,
                  tuple(self.gpu_ids),
              )
  
      # Create some actors.
      actors = [Actor1.remote() for _ in range(0 + 5 + 10)]
      # Make sure that no two actors are assigned to the same GPU.
      locations_and_ids = ray.get(
          [actor.get_location_and_ids.remote() for actor in actors]
      )
      node_names = {location for location, gpu_id in locations_and_ids}
      assert len(node_names) == 2
      for node_name in node_names:
          node_gpu_ids = [
              gpu_id
              for location, gpu_id in locations_and_ids
              if location == node_name
          ]
          assert len(node_gpu_ids) in [5, 10]
          assert set(node_gpu_ids) == {
              (i,) for i in range(len(node_gpu_ids))
          }
  
      # Creating a new actor should fail because all of the GPUs are being
      # used.
      a = Actor1.remote()
      ready_ids, _ = ray.wait(
          [a.get_location_and_ids.remote()], timeout=0.01
      )
      assert ready_ids == []
  
imports: import collections
  import os
  import sys
  import time
  import pytest
  import ray
  import ray.cluster_utils
label_desc: Use image node_id 6 for calling a global function with example usage: test_actor_different_numbers_of_gpus(ray_start_cluster) and returns: ray,  tuple