code: def test_multi_step(
      ray_start_4_cpus_2_gpus_extra, resource_manager_cls
  ):
      """Test that trials can run for more than one iteration.
  
      Todo (krfricke): This is not a resource test, so it should be moved.
  
      Legacy test: test_trial_runner.py::TrialRunnerTest::testMultiStepRun
      Legacy test: test_trial_runner.py::TrialRunnerTest::testMultiStepRun2
      """
      snapshot = TrialStatusSnapshot()
      runner = TuneController(
          resource_manager_factory=lambda: resource_manager_cls(),
          callbacks=[TrialStatusSnapshotTaker(snapshot)],
          storage=STORAGE,
      )
      kwargs = {
          "stopping_criterion": {"training_iteration": 5},
          "placement_group_factory": PlacementGroupFactory(
              [{"CPU": 1, "GPU": 1}]
          ),
          "storage": STORAGE,
      }
      trials = [Trial("__fake", **kwargs) for i in range(2)]
      for t in trials:
          runner.add_trial(t)
  
      while not runner.is_finished():
          runner.step()
  
      # Overstepping should throw error
      # test_trial_runner.py::TrialRunnerTest::testMultiStepRun2
      with pytest.raises(TuneError):
          runner.step()
  
      assert snapshot.all_trials_are_terminated()
      assert all(
          t.last_result["training_iteration"] == 5
          for t in runner.get_trials()
      )
  
imports: import os
  import time
  from collections import Counter
  import pytest
  import sys
  import ray
  from ray import tune
  from ray.air.execution import FixedResourceManager, PlacementGroupResourceManager
  from ray.tune import PlacementGroupFactory, TuneError
  from ray.tune.execution.tune_controller import TuneController
  from ray.tune.experiment import Trial
  from ray.tune.schedulers import FIFOScheduler, TrialScheduler
  from ray.tune.search import BasicVariantGenerator
  from ray.tune.utils.mock import TrialStatusSnapshot, TrialStatusSnapshotTaker
  from ray.train.tests.util import mock_storage_context
label_desc: Use image node_id 4 for calling a global function with example usage: test_multi_step(ray_start_4_cpus_2_gpus_extra, resource_manager_cls) without return types