code: def test_creating_more_actors_than_resources(shutdown_only):
      ray.init(
          num_cpus=10, num_gpus=2, resources={"CustomResource1": 1}
      )
  
      @ray.remote(num_gpus=1)
      class ResourceActor1:
          def method(self):
              return ray.get_gpu_ids()[0]
  
      @ray.remote(resources={"CustomResource1": 1})
      class ResourceActor2:
          def method(self):
              pass
  
      # Make sure the first two actors get created and the third one does
      # not.
      actor1 = ResourceActor1.remote()
      result1 = actor1.method.remote()
      ray.wait([result1])
      actor2 = ResourceActor1.remote()
      result2 = actor2.method.remote()
      ray.wait([result2])
      actor3 = ResourceActor1.remote()
      result3 = actor3.method.remote()
      ready_ids, _ = ray.wait([result3], timeout=0.2)
      assert len(ready_ids) == 0
  
      # By deleting actor1, we free up resources to create actor3.
      del actor1
  
      results = ray.get([result1, result2, result3])
      assert results[0] == results[2]
      assert set(results) == {0, 1}
  
      # Make sure that when one actor goes out of scope a new actor is
      # created because some resources have been freed up.
      results = []
      for _ in range(3):
          actor = ResourceActor2.remote()
          object_ref = actor.method.remote()
          results.append(object_ref)
          # Wait for the task to execute. We do this because otherwise it may
          # be possible for the __ray_terminate__ task to execute before the
          # method.
          ray.wait([object_ref])
  
      ray.get(results)
  
imports: import collections
  import os
  import sys
  import time
  import pytest
  import ray
  import ray.cluster_utils
label_desc: Use image node_id 13 for calling a global function with example usage: test_creating_more_actors_than_resources(shutdown_only) and returns: ray