code: def test_restore_with_datasets(ray_start_4_cpus, tmpdir):
      """Datasets are required to re-specify if they were originally provided."""
      datasets = {
          "train": ray.data.from_items(
              [{"x": x, "y": x + 1} for x in range(8)]
          ),
          "valid": ray.data.from_items(
              [{"x": x, "y": x + 1} for x in range(8)]
          ),
      }
  
      trainer = DataParallelTrainer(
          train_loop_per_worker=lambda config: train.report(
              {"score": 1}
          ),
          datasets=datasets,
          scaling_config=ScalingConfig(num_workers=2),
          run_config=RunConfig(
              name="datasets_respecify_test", local_dir=tmpdir
          ),
      )
      trainer._save(tmpdir)
  
      # Restore should complain, if all the datasets don't get passed in again
      with pytest.raises(ValueError):
          DataParallelTrainer.restore(str(tmpdir))
  
      with pytest.raises(ValueError):
          DataParallelTrainer.restore(
              str(tmpdir), datasets={"train": datasets["train"]}
          )
  
      with pytest.raises(ValueError):
          DataParallelTrainer.restore(
              str(tmpdir),
              datasets={
                  "train": datasets["train"],
                  "invalid_key": datasets["valid"],
              },
          )
  
      trainer = DataParallelTrainer.restore(
          str(tmpdir), datasets=datasets
      )
  
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 7 for calling a global function with example usage: test_restore_with_datasets(ray_start_4_cpus, tmpdir) without return types