code: def test_multi_trial_reuse(
      trainable, ray_start_4_cpus_extra, monkeypatch, tmp_path
  ):
      """Test that actors from multiple trials running in parallel will be reused.
  
      - 2 trials can run at the same time
      - Trial 3 will be scheduled after trial 1 succeeded, so will reuse actor
      - Trial 4 will be scheduled after trial 2 succeeded, so will reuse actor
      """
      monkeypatch.setenv("TUNE_MAX_PENDING_TRIALS_PG", "2")
  
      register_trainable("foo2", trainable)
  
      messages = ["First", "Second", "Third", "Fourth"]
      # We sleep here for one second so that the third actor
      # does not finish training before the fourth can be scheduled.
      # This helps ensure that both remote runners are re-used and
      # not just one.
      [trial1, trial2, trial3, trial4] = tune.run(
          "foo2",
          config={
              "id": tune.grid_search(list(range(4))),
              "message": tune.sample_from(
                  lambda config: messages[config["id"]]
              ),
              "marker_dir": tmp_path,
              "sleep": 2,
          },
          reuse_actors=True,
          resources_per_trial={"cpu": 2},
      ).trials
  
      assert trial3.last_result["num_resets"] == 1
      assert trial4.last_result["num_resets"] == 1
  
imports: import inspect
  import os
  from pathlib import Path
  import tempfile
  from typing import Callable
  import pytest
  import sys
  import time
  import ray
  from ray import train, tune, logger
  from ray.train import CheckpointConfig
  from ray.tune import Trainable, run_experiments, register_trainable
  from ray.tune.error import TuneError
  from ray.tune.result_grid import ResultGrid
  from ray.tune.schedulers.trial_scheduler import FIFOScheduler, TrialScheduler
  from ray.tune.tune import _check_mixin
  from ray.train.tests.util import create_dict_checkpoint, load_dict_checkpoint
label_desc: Use image node_id 13 for calling a global function with example usage: test_multi_trial_reuse(trainable, ray_start_4_cpus_extra, monkeypatch, tmp_path) without return types