code: def main(bucket_uri: str):
      ray.init(
          log_to_driver=True,
          runtime_env={"working_dir": os.path.dirname(__file__)},
      )
      num_samples = int(ray.cluster_resources()["CPU"])
  
      tuner = Tuner(
          objective,
          param_space={
              "start_time": time.monotonic(),
              "warmup_time_s": WARMUP_TIME_S,
          },
          tune_config=TuneConfig(
              num_samples=num_samples, metric="iteration", mode="max"
          ),
          run_config=RunConfig(
              verbose=2,
              failure_config=FailureConfig(max_failures=-1),
              storage_path=bucket_uri,
              checkpoint_config=CheckpointConfig(num_to_keep=2),
          ),
      )
  
      instance_killer = create_instance_killer(
          probability=0.03,
          time_between_checks_s=10,
          warmup_time_s=WARMUP_TIME_S,
      )
      results = tuner.fit()
      print("Fitted:", results)
  
      del instance_killer
      print("Deleted instance killer")
      gc.collect()
      print("Collected garbage")
  
      for result in results:
          checkpoint = result.checkpoint
          with checkpoint.as_directory() as checkpoint_dir:
              with open(
                  os.path.join(checkpoint_dir, "ckpt.pkl"), "rb"
              ) as f:
                  checkpoint_dict = pickle.load(f)
  
          assert checkpoint_dict["iteration"] == MAX_ITERS, (
              checkpoint_dict,
              MAX_ITERS,
          )
          assert (
              checkpoint_dict["iteration"]
              == result.metrics["iteration"]
          ), result
  
file_path: ray/release/tune_tests/fault_tolerance_tests/workloads/test_tune_worker_fault_tolerance.py
imports: import os
  import pickle
  import argparse
  import tempfile
  import time
  import random
  import gc
  import ray
  from ray import train
  from ray.train import Checkpoint, RunConfig, FailureConfig, CheckpointConfig
  from ray.tune.tune_config import TuneConfig
  from ray.tune.tuner import Tuner
  from terminate_node_aws import create_instance_killer
label_desc: Use image node_id 2 for calling a global function with example usage: main(bucket_uri) without return types