code: def test_remove_actor_tracking(
      ray_start_4_cpus_2_gpus_extra, resource_manager_cls
  ):
      """When we reuse actors, actors that have been requested but not started
      should not be tracked in ``_stopping_actors``.
  
      When actors are re-used, we cancel original actor requests for the trial.
      If these actors haven't been alive, there won't be a stop future to be resolved,
      and thus they would remain in ``TuneController._stopping_actors`` until they
      get cleaned up after 600 seconds.
  
      This test asserts that these actors are not tracked in
      ``TuneController._stopping_actors`` at all.
  
      We start 4 actors, and one can run at a time. Actors are re-used across trials.
      When the experiment ends, we expect that only one actor is left to track
      in ``self._stopping_trials``.
      """
      runner = TuneController(
          resource_manager_factory=lambda: resource_manager_cls(),
          reuse_actors=True,
          storage=STORAGE,
      )
  
      def train_fn(config):
          return 1
  
      register_trainable("test_remove_actor_tracking", train_fn)
  
      kwargs = {
          "placement_group_factory": PlacementGroupFactory(
              [{"CPU": 4, "GPU": 2}]
          ),
          "storage": STORAGE,
      }
      trials = [
          Trial("test_remove_actor_tracking", **kwargs)
          for i in range(4)
      ]
      for t in trials:
          runner.add_trial(t)
  
      while not runner.is_finished():
          runner.step()
  
      # Only one actor should be left to stop
      assert len(runner._stopping_actors) == 1
  
      runner.cleanup()
  
      assert len(runner._stopping_actors) == 0
  
file_path: ray/python/ray/tune/tests/execution/test_controller_control_integration.py
imports: from collections import Counter
  import pytest
  import sys
  import ray
  from ray.air.execution import FixedResourceManager, PlacementGroupResourceManager
  from ray.tune import PlacementGroupFactory, register_trainable
  from ray.tune.execution.tune_controller import TuneController
  from ray.tune.experiment import Trial
  from ray.train.tests.util import mock_storage_context
label_desc: Use image node_id 3 for calling a global function with example usage: test_remove_actor_tracking(ray_start_4_cpus_2_gpus_extra, resource_manager_cls) and returns: int