code: def test_gbdt_trainer_restore(
      ray_start_6_cpus, tmp_path, trainer_cls, monkeypatch
  ):
      """Tests restoring gradient boosted decision tree trainers.
      Success criteria:
      - Picks up at the right iteration. 2 before crash. 3 after. 5 total trees.
      - Results are being logged to the same directory as before.
      """
      # TODO(krfricke): Re-enable this once gbdt trainers are supported.
      # Also runs into the same problem as the test below.
      pytest.skip("GBDT trainers are not supported yet.")
      monkeypatch.setenv("RAY_AIR_LOCAL_CACHE_DIR", str(tmp_path))
      exp_name = f"{trainer_cls.__name__}_restore_test"
      datasets = {
          "train": ray.data.from_items(
              [{"x": x, "y": x + 1} for x in range(100)]
          )
      }
  
      fail_marker_path = tmp_path / "fail_marker"
      fail_marker_path.touch()
  
      trainer = trainer_cls(
          label_column="y",
          params={
              "objective": (
                  "reg:squarederror"
                  if trainer_cls == XGBoostTrainer
                  else "regression"
              )
          },
          datasets=datasets,
          scaling_config=ScalingConfig(
              num_workers=2,
              trainer_resources={"CPU": 0},
              resources_per_worker={"CPU": 1},
          ),
          run_config=RunConfig(
              name=exp_name,
              checkpoint_config=CheckpointConfig(
                  num_to_keep=1,
                  checkpoint_frequency=1,
                  checkpoint_at_end=False,
              ),
              callbacks=[
                  FailureInjectionCallback(
                      fail_marker_path, num_iters=2
                  )
              ],
          ),
          num_boost_round=5,
      )
      with pytest.raises(TrainingFailedError):
          result = trainer.fit()
  
      trainer = trainer_cls.restore(
          str(tmp_path / exp_name), datasets=datasets
      )
      result = trainer.fit()
      assert not result.error
      assert result.metrics["training_iteration"] == 5
      assert result.metrics["iterations_since_restore"] == 3
      assert tmp_path / exp_name in Path(result.path).parents
  
imports: import warnings
  from pathlib import Path
  from typing import Dict, List
  import pytest
  import ray
  from ray import train
  from ray.air._internal.uri_utils import URI
  from ray.train import CheckpointConfig, RunConfig, ScalingConfig
  from ray.train.base_trainer import BaseTrainer
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.lightgbm import LightGBMTrainer
  from ray.train.tests.util import create_dict_checkpoint, load_dict_checkpoint
  from ray.train.torch import TorchTrainer
  from ray.train.trainer import TrainingFailedError
  from ray.train.xgboost import XGBoostTrainer
  from ray.tune import Callback
  from ray.tune.experiment import Trial
label_desc: Use image node_id 5 for calling a global function with example usage: test_gbdt_trainer_restore(ray_start_6_cpus, tmp_path, trainer_cls, monkeypatch) without return types