code: def test_placement_group_table(ray_start_cluster, connect_to_client):
      @ray.remote(num_cpus=2)
      class Actor(object):
          def __init__(self):
              self.n = 0
  
          def value(self):
              return self.n
  
      cluster = ray_start_cluster
      num_nodes = 2
      for _ in range(num_nodes):
          cluster.add_node(num_cpus=4)
      ray.init(address=cluster.address)
      pgs_created = []
  
      with connect_to_client_or_not(connect_to_client):
          # Originally placement group creation should be pending because
          # there are no resources.
          name = "name"
          strategy = "PACK"
          bundles = [{"CPU": 2, "GPU": 1}, {"CPU": 2}]
          placement_group = ray.util.placement_group(
              name=name, strategy=strategy, bundles=bundles
          )
          pgs_created.append(placement_group)
          result = ray.util.placement_group_table(placement_group)
          assert result["name"] == name
          assert result["strategy"] == strategy
          for i in range(len(bundles)):
              assert bundles[i] == result["bundles"][i]
          assert result["state"] == "PENDING"
  
          # Now the placement group should be scheduled.
          cluster.add_node(num_cpus=5, num_gpus=1)
          cluster.wait_for_nodes()
  
          actor_1 = Actor.options(
              scheduling_strategy=PlacementGroupSchedulingStrategy(
                  placement_group=placement_group,
                  placement_group_bundle_index=0,
              )
          ).remote()
          ray.get(actor_1.value.remote())
  
          result = ray.util.placement_group_table(placement_group)
          assert result["state"] == "CREATED"
  
          # Add tow more placement group for placement group table test.
          second_strategy = "SPREAD"
          pgs_created.append(
              ray.util.placement_group(
                  name="second_placement_group",
                  strategy=second_strategy,
                  bundles=bundles,
              )
          )
          pgs_created.append(
              ray.util.placement_group(
                  name="third_placement_group",
                  strategy=second_strategy,
                  bundles=bundles,
              )
          )
  
          placement_group_table = ray.util.placement_group_table()
          assert len(placement_group_table) == 3
  
          true_name_set = {
              "name",
              "second_placement_group",
              "third_placement_group",
          }
          get_name_set = set()
  
          for _, placement_group_data in placement_group_table.items():
              get_name_set.add(placement_group_data["name"])
  
          assert true_name_set == get_name_set
  
          placement_group_assert_no_leak(pgs_created)
  
imports: import pytest
  import os
  import sys
  import ray
  import ray.cluster_utils
  from ray._private.test_utils import get_other_nodes, wait_for_condition, is_placement_group_removed, placement_group_assert_no_leak
  from ray._raylet import PlacementGroupID
  from ray.util.placement_group import PlacementGroup
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  from ray.util.client.ray_client_helpers import connect_to_client_or_not
  from ray._private.runtime_env.context import RuntimeEnvContext
  from ray._private.runtime_env.plugin import RuntimeEnvPlugin
label_desc: Use image node_id 4 for calling a global function with example usage: test_placement_group_table(ray_start_cluster, connect_to_client) and returns: self