code: def test_kill_inactive_pending_over_idle(
      self, ray_start_regular_shared
  ):
      # Test that a killing pending actors is prioritized over killing idle actors on
      # the kill_inactive_actor() call.
      pool = _ActorPool()
      # Add pending worker.
      pending_actor = PoolWorker.remote()
      ready_ref = pending_actor.get_location.remote()
      pool.add_pending_actor(pending_actor, ready_ref)
      # Add idle worker.
      idle_actor = self._add_ready_worker(pool)
      # Kill inactive actor.
      killed = pool.kill_inactive_actor()
      # Check that an actor was killed.
      assert killed
      # Check that the idle actor is still in the pool.
      assert pool.pick_actor() == idle_actor
      pool.return_actor(idle_actor)
      # Check that the pending actor is not in pool.
      assert pool.get_pending_actor_refs() == []
      # Check that actor was killed.
      # Wait a second to let actor killing happen.
      time.sleep(1)
      with pytest.raises(ray.exceptions.RayActorError):
          ray.get(pending_actor.get_location.remote())
      # Check that the per-state pool sizes are as expected.
      assert pool.num_total_actors() == 1
      assert pool.num_pending_actors() == 0
      assert pool.num_running_actors() == 1
      assert pool.num_active_actors() == 0
      assert pool.num_idle_actors() == 1
      assert pool.num_free_slots() == 4
  
imports: import collections
  import time
  import pytest
  import ray
  from ray.data._internal.compute import ActorPoolStrategy
  from ray.data._internal.execution.operators.actor_pool_map_operator import AutoscalingConfig, AutoscalingPolicy, _ActorPool
  from ray.data._internal.execution.util import make_ref_bundles
  from ray.tests.conftest import *
label_desc: Use image node_id 14 for calling the TestActorPool obj's underlying member method code with example usage: obj.test_kill_inactive_pending_over_idle(ray_start_regular_shared) without return types