code: def test_invalid_param_space(shutdown_only):
      """Check that Tune raises an error on invalid param_space types."""
  
      def trainable(config):
          return {"metric": 1}
  
      with pytest.raises(ValueError):
          Tuner(trainable, param_space="not allowed")
  
      from ray.tune.tune import _Config
  
      class CustomConfig(_Config):
          def to_dict(self) -> dict:
              return {"hparam": 1}
  
      with pytest.raises(ValueError):
          Tuner(trainable, param_space="not allowed").fit()
  
      with pytest.raises(ValueError):
          tune.run(trainable, config="not allowed")
  
      # Dict and custom _Config subclasses are fine
      Tuner(trainable, param_space={}).fit()
      Tuner(trainable, param_space=CustomConfig()).fit()
      tune.run(trainable, config=CustomConfig())
  
imports: import os
  from pathlib import Path
  from unittest.mock import patch
  import pytest
  import unittest
  from typing import Optional
  from sklearn.datasets import load_breast_cancer
  from sklearn.utils import shuffle
  import ray
  from ray import train, tune
  from ray.train import CheckpointConfig, RunConfig, ScalingConfig
  from ray.train.constants import RAY_CHDIR_TO_TRIAL_DIR
  from ray.train.examples.pytorch.torch_linear_example import train_func
  from ray.data import Dataset, Datasource, ReadTask, from_pandas, read_datasource
  from ray.data.block import BlockMetadata
  from ray.train.data_parallel_trainer import DataParallelTrainer
  from ray.train.torch import TorchTrainer
  from ray.train.trainer import BaseTrainer
  from ray.train.xgboost import XGBoostTrainer
  from ray.tune import Callback, CLIReporter
  from ray.tune.tune_config import TuneConfig
  from ray.tune.tuner import Tuner
label_desc: Use image node_id 16 for calling a global function with example usage: test_invalid_param_space(shutdown_only) and returns: dict, dict