code: def test_trainable_error_with_tuner(
      ray_start_4_cpus, fail_fast, trainable_type
  ):
      trainable = trainable_map[trainable_type]
  
      tuner = Tuner(
          trainable=trainable,
          run_config=RunConfig(
              name=f"tuner_errors-fail_fast={fail_fast}-trainable_type={trainable_type}",
              failure_config=FailureConfig(fail_fast=fail_fast),
          ),
          tune_config=TuneConfig(num_samples=2),
      )
  
      if fail_fast is False:
          # Both trials should complete with an error.
          results = tuner.fit()
          assert len(results) == 2
          for i in range(2):
              assert results[i].error
      elif fail_fast is True:
          # The first trial errors -> the experiment finishes immediately.
          results = tuner.fit()
          errors = [result.error for result in results if result.error]
          assert len(errors) == 1
      elif fail_fast == "raise":
          # The original error gets raised to the user
          with pytest.raises(_TestSpecificError):
              tuner.fit()
  
imports: import gc
  import threading
  import time
  from tempfile import TemporaryDirectory
  import pytest
  import ray
  from ray import train, tune
  from ray._private.test_utils import wait_for_condition
  from ray._raylet import GcsClient
  from ray.cluster_utils import Cluster
  from ray.core.generated import autoscaler_pb2
  from ray.train import Checkpoint, FailureConfig, RunConfig, ScalingConfig
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.trainer import BaseTrainer, TrainingFailedError
  from ray.tune import Tuner, TuneConfig, TuneError
  from ray.tests.conftest import *
  from ray.train.tests.util import create_dict_checkpoint, load_dict_checkpoint
label_desc: Use image node_id 6 for calling a global function with example usage: test_trainable_error_with_tuner(ray_start_4_cpus, fail_fast, trainable_type) without return types