code: def test_clear_state(ray_start_4_cpus):
      """Test that clearing state will remove existing placement groups.
  
      - Create resource request
      - Wait until PG is scheduled
      - Assert that Ray PG is created
      - Call `mgr.clear()`
      - Assert that resources are not ready anymore
      - Assert that Ray PG is removed
      """
      manager = PlacementGroupResourceManager(update_interval_s=0)
      manager.request_resources(REQUEST_1_2_CPU)
      ray.wait(manager.get_resource_futures(), num_returns=1)
  
      assert manager.has_resources_ready(REQUEST_1_2_CPU)
  
      pg_states = _count_pg_states()
      assert pg_states["CREATED"] == 1
      assert pg_states["PENDING"] == 0
      assert pg_states["REMOVED"] == 0
  
      manager.clear()
  
      assert not manager.has_resources_ready(REQUEST_1_2_CPU)
  
      pg_states = _count_pg_states()
      assert pg_states["CREATED"] == 0
      assert pg_states["PENDING"] == 0
      assert pg_states["REMOVED"] == 1
  
file_path: ray/python/ray/air/tests/execution/test_resource_manager_placement_group.py
imports: import time
  from collections import Counter
  import pytest
  import ray
  from ray.air.execution.resources.placement_group import PlacementGroupResourceManager
  from ray.air.execution.resources.request import ResourceRequest
label_desc: Use image node_id 10 for calling a global function with example usage: test_clear_state(ray_start_4_cpus) without return types