code: def test_placement_group_invalid_resource_request(shutdown_only):
      """
      Make sure exceptions are raised if
      requested resources don't fit any bundles.
      """
      ray.init(resources={"a": 1})
      pg = ray.util.placement_group(bundles=[{"a": 1}])
  
      #
      # Test an actor with 0 cpu.
      #
      @ray.remote
      class A:
          def ready(self):
              pass
  
      # The actor cannot be scheduled with the default because
      # it requires 1 cpu for the placement, but the pg doesn't have it.
      with pytest.raises(ValueError):
          a = A.options(
              scheduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              )
          ).remote()
      # Shouldn't work with 1 CPU because pg doesn't contain CPUs.
      with pytest.raises(ValueError):
          a = A.options(
              num_cpus=1,
              scheduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              ),
          ).remote()
      # 0 CPU should work.
      a = A.options(
          num_cpus=0,
          scheduling_strategy=PlacementGroupSchedulingStrategy(
              placement_group=pg
          ),
      ).remote()
      ray.get(a.ready.remote())
      del a
  
      #
      # Test an actor with non-0 resources.
      #
      @ray.remote(resources={"a": 1})
      class B:
          def ready(self):
              pass
  
      # When resources are given to the placement group,
      # it automatically adds 1 CPU to resources, so it should fail.
      with pytest.raises(ValueError):
          b = B.options(
              scheduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              )
          ).remote()
      # If 0 cpu is given, it should work.
      b = B.options(
          num_cpus=0,
          scheduling_strategy=PlacementGroupSchedulingStrategy(
              placement_group=pg
          ),
      ).remote()
      ray.get(b.ready.remote())
      del b
      # If resources are requested too much, it shouldn't work.
      with pytest.raises(ValueError):
          # The actor cannot be scheduled with no resource specified.
          # Note that the default actor has 0 cpu.
          B.options(
              num_cpus=0,
              resources={"a": 2},
              schduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              ),
          ).remote()
  
      #
      # Test a function with 1 CPU.
      #
      @ray.remote
      def f():
          pass
  
      # 1 CPU shouldn't work because the pg doesn't have CPU bundles.
      with pytest.raises(ValueError):
          f.options(
              schduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              )
          ).remote()
      # 0 CPU should work.
      ray.get(
          f.options(
              scheduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              ),
              num_cpus=0,
          ).remote()
      )
  
      #
      # Test a function with 0 CPU.
      #
      @ray.remote(num_cpus=0)
      def g():
          pass
  
      # 0 CPU should work.
      ray.get(
          g.options(
              scheduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=pg
              )
          ).remote()
      )
  
      placement_group_assert_no_leak([pg])
  
imports: import sys
  import warnings
  import os
  import pytest
  import ray
  from ray._private.utils import get_ray_doc_version
  import ray.cluster_utils
  from ray._private.test_utils import placement_group_assert_no_leak
  from ray._private.test_utils import skip_flaky_core_test_premerge
  from ray.util.client.ray_client_helpers import connect_to_client_or_not
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 3 for calling a global function with example usage: test_placement_group_invalid_resource_request(shutdown_only) without return types