code: def build_dummy_trainer(configs):
      def worker_loop(_config):
          for i in range(configs["NUM_ITERATIONS"]):
              # Do some random reports in between checkpoints.
              train.report({"metric_a": -100, "metric_b": -100})
  
              if ray.train.get_context().get_world_rank() == 0:
                  with create_dict_checkpoint(
                      {"iter": i}
                  ) as checkpoint:
                      train.report(
                          metrics={"metric_a": i, "metric_b": -i},
                          checkpoint=checkpoint,
                      )
              else:
                  train.report(metrics={"metric_a": i, "metric_b": -i})
          raise RuntimeError()
  
      trainer = TorchTrainer(
          train_loop_per_worker=worker_loop,
          train_loop_config=_PARAM_SPACE,
          scaling_config=ScalingConfig(num_workers=2, use_gpu=False),
          run_config=RunConfig(
              name=configs["EXP_NAME"],
              storage_path=configs["STORAGE_PATH"],
              checkpoint_config=CheckpointConfig(
                  num_to_keep=configs["NUM_CHECKPOINTS"],
                  checkpoint_score_attribute="metric_a",
                  checkpoint_score_order="max",
              ),
          ),
      )
      return trainer
  
file_path: ray/python/ray/train/tests/test_result.py
imports: import pyarrow
  import pytest
  import ray
  from ray import train
  from ray.air._internal.uri_utils import URI
  from ray.air.constants import EXPR_RESULT_FILE
  from ray.train import CheckpointConfig, Result, RunConfig, ScalingConfig
  from ray.train.base_trainer import TrainingFailedError
  from ray.train.tests.util import create_dict_checkpoint, load_dict_checkpoint
  from ray.train.torch import TorchTrainer
  from ray.tune import TuneConfig, Tuner
label_desc: Use image node_id 2 for calling a global function with example usage: build_dummy_trainer(configs) and returns: trainer