code: def train_fn(config):
      start_epoch = 0
  
      print(train.get_context().get_trial_resources())
      checkpoint = train.get_checkpoint()
      if checkpoint:
          # assume that we have run the train.report() example
          # and successfully save some model weights
          with checkpoint.as_directory() as tmpdir:
              with open(
                  os.path.join(tmpdir, "checkpoint.json"), "r"
              ) as fin:
                  checkpoint_dict = json.load(fin)
  
          start_epoch = checkpoint_dict.get("epoch", -1) + 1
  
      # wrap the model in DDP
      for epoch in range(start_epoch, config["num_epochs"]):
          with TemporaryDirectory() as tmpdir:
              with open(
                  os.path.join(tmpdir, "checkpoint.json"), "w"
              ) as fout:
                  json.dump(dict(epoch=epoch), fout)
  
              train.report(
                  {
                      "metric": config["metric"] * epoch,
                      "epoch": epoch,
                      "num_cpus": train.get_context()
                      .get_trial_resources()
                      .required_resources["CPU"],
                  },
                  checkpoint=Checkpoint.from_directory(tmpdir),
              )
  
imports: import os
  from ray import train
  from ray.train import Checkpoint, FailureConfig, RunConfig, ScalingConfig
  from ray.air.constants import TRAIN_DATASET_KEY
  from ray.tune.tune_config import TuneConfig
  from ray.tune.tuner import Tuner
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.xgboost import XGBoostTrainer
  from sklearn.datasets import load_breast_cancer
  import pandas
  import pytest
  import ray
  import json
  from tempfile import TemporaryDirectory
  from ray import tune
  from ray.tune.schedulers.resource_changing_scheduler import DistributeResources, ResourceChangingScheduler
  from ray.tune.schedulers.async_hyperband import ASHAScheduler
label_desc: Use image node_id 2 for calling a global function with example usage: train_fn(config) without return types