code: def test_trial_requeue(
      start_connected_emptyhead_cluster, tmpdir, storage
  ):
      """Removing a node in full cluster causes Trial to be requeued."""
      os.environ["TUNE_MAX_PENDING_TRIALS_PG"] = "1"
  
      cluster = start_connected_emptyhead_cluster
      node = cluster.add_node(num_cpus=1)
      cluster.wait_for_nodes()
  
      runner = TuneController(
          search_alg=BasicVariantGenerator(), storage=storage
      )
      kwargs = {
          "stopping_criterion": {"training_iteration": 5},
          "checkpoint_config": CheckpointConfig(checkpoint_frequency=1),
          "max_failures": 1,
          "storage": storage,
      }
  
      trials = [Trial("__fake", **kwargs), Trial("__fake", **kwargs)]
      for t in trials:
          runner.add_trial(t)
  
      while not any(t.status == Trial.RUNNING for t in trials):
          runner.step()
  
      runner.step()
      runner.step()
  
      running_trials = _get_running_trials(runner)
      assert len(running_trials) == 1
      assert _check_trial_running(running_trials[0])
      cluster.remove_node(node)
      cluster.wait_for_nodes()
      time.sleep(
          0.1
      )  # Sleep so that next step() refreshes cluster resources
      runner.step()  # Process result, dispatch save
      runner.step()  # Process save (detect error), requeue trial
      assert all(t.status == Trial.PENDING for t in trials)
  
imports: import time
  import os
  import pytest
  import sys
  from unittest.mock import MagicMock
  import ray
  from ray import tune
  from ray.train import CheckpointConfig
  from ray.cluster_utils import Cluster
  from ray.train._internal.storage import StorageContext
  from ray.tune.error import TuneError
  from ray.tune.search import BasicVariantGenerator
  from ray.tune.experiment import Trial
  from ray.tune.execution.tune_controller import TuneController
label_desc: Use image node_id 10 for calling a global function with example usage: test_trial_requeue(start_connected_emptyhead_cluster, tmpdir, storage) without return types