code: def test_scaling_config_validation(ray_start_4_cpus):
      def train_func(config):
          train.report({"loss": config["x"]})
  
      # Should be able to create a DataParallelTrainer w/o scaling_config,
      # but it should fail on fit
      trainer = DataParallelTrainer(
          train_loop_per_worker=train_func,
          train_loop_config={"x": 100},
      )
      with pytest.raises(ValueError):
          trainer.fit()
  
      # Scaling config must be passed in through Tuner param space if not
      # included in the initial trainer
      tuner = Tuner(trainer)
      with pytest.raises(ValueError):
          tuner.fit()
  
      tuner = Tuner(
          trainer,
          param_space={"scaling_config": ScalingConfig(num_workers=1)},
      )
      results = tuner.fit()
      assert not results.errors
  
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 12 for calling a global function with example usage: test_scaling_config_validation(ray_start_4_cpus) without return types