code: def test_datasets(ray_start_4_cpus):
      num_train_data = 10
      num_val_data = 6
  
      train_dataset = ray.data.range(num_train_data)
      val_dataset = ray.data.range(num_val_data)
  
      def get_dataset():
          # Train dataset should be sharded.
          train_dataset = train.get_dataset_shard("train")
          train_ds_count = len(list(train_dataset.iter_rows()))
          assert (
              train_ds_count
              == num_train_data / scale_config.num_workers
          )
          # All other datasets should not be sharded.
          val_dataset = train.get_dataset_shard("val")
          val_ds_count = len(list(val_dataset.iter_rows()))
          assert val_ds_count == num_val_data / scale_config.num_workers
  
      trainer = DataParallelTrainer(
          train_loop_per_worker=get_dataset,
          scaling_config=scale_config,
          datasets={"train": train_dataset, "val": val_dataset},
      )
      trainer.fit()
  
imports: import os
  import time
  from unittest.mock import patch
  import pytest
  import ray
  from ray import train, tune
  from ray.train import RunConfig, ScalingConfig
  from ray.train._internal.backend_executor import BackendExecutor
  from ray.train._internal.worker_group import WorkerGroup
  from ray.train.backend import Backend, BackendConfig
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.tests.util import create_dict_checkpoint, load_dict_checkpoint
  from ray.tune.callback import Callback
  from ray.tune.tune_config import TuneConfig
  from ray.tune.tuner import Tuner
label_desc: Use image node_id 8 for calling a global function with example usage: test_datasets(ray_start_4_cpus) without return types