code: def test_input_validation():
      """Check that guarded input validation raises errors"""
  
      for Symbolic in (SymbolicRegressor, SymbolicTransformer):
          # Check too much proba
          est = Symbolic(p_point_mutation=0.5)
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
  
          # Check invalid init_method
          est = Symbolic(init_method="ni")
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
  
          # Check invalid const_ranges
          est = Symbolic(const_range=2)
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(const_range=[2, 2])
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(const_range=(2, 2, 2))
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(const_range="ni")
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          # And check acceptable, but strange, representations of const_range
          est = Symbolic(
              population_size=100, generations=1, const_range=(2, 2)
          )
          est.fit(diabetes.data, diabetes.target)
          est = Symbolic(
              population_size=100, generations=1, const_range=None
          )
          est.fit(diabetes.data, diabetes.target)
          est = Symbolic(
              population_size=100, generations=1, const_range=(4, 2)
          )
          est.fit(diabetes.data, diabetes.target)
  
          # Check invalid init_depth
          est = Symbolic(init_depth=2)
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(init_depth=2)
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(init_depth=[2, 2])
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(init_depth=(2, 2, 2))
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(init_depth="ni")
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          est = Symbolic(init_depth=(4, 2))
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
          # And check acceptable, but strange, representations of init_depth
          est = Symbolic(
              population_size=100, generations=1, init_depth=(2, 2)
          )
          est.fit(diabetes.data, diabetes.target)
  
      # Check hall_of_fame and n_components for transformer
      est = SymbolicTransformer(hall_of_fame=2000)
      assert_raises(ValueError, est.fit, diabetes.data, diabetes.target)
      est = SymbolicTransformer(n_components=2000)
      assert_raises(ValueError, est.fit, diabetes.data, diabetes.target)
      est = SymbolicTransformer(hall_of_fame=0)
      assert_raises(ValueError, est.fit, diabetes.data, diabetes.target)
      est = SymbolicTransformer(n_components=0)
      assert_raises(ValueError, est.fit, diabetes.data, diabetes.target)
  
      # Check regressor metrics
      for m in [
          "mean absolute error",
          "mse",
          "rmse",
          "pearson",
          "spearman",
      ]:
          est = SymbolicRegressor(
              population_size=100, generations=1, metric=m
          )
          est.fit(diabetes.data, diabetes.target)
      # And check a fake one
      est = SymbolicRegressor(metric="the larch")
      assert_raises(ValueError, est.fit, diabetes.data, diabetes.target)
      # Check transformer metrics
      for m in ["pearson", "spearman"]:
          est = SymbolicTransformer(
              population_size=100, generations=1, metric=m
          )
          est.fit(diabetes.data, diabetes.target)
      # And check the regressor metrics as well as a fake one
      for m in ["mean absolute error", "mse", "rmse", "the larch"]:
          est = SymbolicTransformer(metric=m)
          assert_raises(
              ValueError, est.fit, diabetes.data, diabetes.target
          )
  
imports: import pickle
  import pytest
  import sys
  from io import StringIO
  import numpy
  from scipy.stats import pearsonr, spearmanr
  from sklearn.datasets import load_diabetes, load_breast_cancer
  from sklearn.metrics import mean_absolute_error
  from sklearn.model_selection import GridSearchCV
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import StandardScaler
  from sklearn.tree import DecisionTreeRegressor
  from sklearn.utils._testing import assert_almost_equal
  from sklearn.utils._testing import assert_array_equal
  from sklearn.utils._testing import assert_array_almost_equal
  from sklearn.utils._testing import assert_raises
  from sklearn.utils.validation import check_random_state
  from gplearn.genetic import SymbolicClassifier, SymbolicRegressor
  from gplearn.genetic import SymbolicTransformer
  from gplearn.fitness import weighted_pearson, weighted_spearman
  from gplearn._program import _Program
  from gplearn.fitness import _fitness_map
  from gplearn.functions import add2, sub2, mul2, div2, sqrt1, log1, abs1, max2, min2
  from gplearn.functions import _Function
label_desc: Use image node_id 12 for calling a global function with example usage: test_input_validation() without return types