code: def test_sample_weight_and_class_weight():
      """Check sample_weight param works"""
  
      # Check constant sample_weight has no effect
      sample_weight = np.ones(diabetes.target.shape[0])
      est1 = SymbolicRegressor(
          population_size=100, generations=2, random_state=0
      )
      est1.fit(diabetes.data, diabetes.target)
      est2 = SymbolicRegressor(
          population_size=100, generations=2, random_state=0
      )
      est2.fit(
          diabetes.data, diabetes.target, sample_weight=sample_weight
      )
      # And again with a scaled sample_weight
      est3 = SymbolicRegressor(
          population_size=100, generations=2, random_state=0
      )
      est3.fit(
          diabetes.data,
          diabetes.target,
          sample_weight=sample_weight * 1.1,
      )
  
      assert_almost_equal(
          est1._program.fitness_, est2._program.fitness_
      )
      assert_almost_equal(
          est1._program.fitness_, est3._program.fitness_
      )
  
      # And again for the classifier
      sample_weight = np.ones(cancer.target.shape[0])
      est1 = SymbolicClassifier(
          population_size=100, generations=2, random_state=0
      )
      est1.fit(cancer.data, cancer.target)
      est2 = SymbolicClassifier(
          population_size=100, generations=2, random_state=0
      )
      est2.fit(cancer.data, cancer.target, sample_weight=sample_weight)
      # And again with a scaled sample_weight
      est3 = SymbolicClassifier(
          population_size=100, generations=2, random_state=0
      )
      est3.fit(
          cancer.data, cancer.target, sample_weight=sample_weight * 1.1
      )
      # And then using class weight to do the same thing
      est4 = SymbolicClassifier(
          class_weight={0: 1, 1: 1},
          population_size=100,
          generations=2,
          random_state=0,
      )
      est4.fit(cancer.data, cancer.target)
      est5 = SymbolicClassifier(
          class_weight={0: 1.1, 1: 1.1},
          population_size=100,
          generations=2,
          random_state=0,
      )
      est5.fit(cancer.data, cancer.target)
  
      assert_almost_equal(
          est1._program.fitness_, est2._program.fitness_
      )
      assert_almost_equal(
          est1._program.fitness_, est3._program.fitness_
      )
      assert_almost_equal(
          est1._program.fitness_, est4._program.fitness_
      )
      assert_almost_equal(
          est1._program.fitness_, est5._program.fitness_
      )
  
      # And again for the transformer
      sample_weight = np.ones(diabetes.target.shape[0])
      est1 = SymbolicTransformer(
          population_size=100, generations=2, random_state=0
      )
      est1 = est1.fit_transform(diabetes.data, diabetes.target)
      est2 = SymbolicTransformer(
          population_size=100, generations=2, random_state=0
      )
      est2 = est2.fit_transform(
          diabetes.data, diabetes.target, sample_weight=sample_weight
      )
  
      assert_array_almost_equal(est1, est2)
  
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 15 for calling a global function with example usage: test_sample_weight_and_class_weight() without return types