code: def test_validate_fitness():
      """Check that valid fitness measures are accepted & invalid raise error"""
  
      # Check arg count checks
      _ = make_fitness(
          function=_mean_square_error, greater_is_better=True
      )
      # non-bool greater_is_better
      assert_raises(
          ValueError,
          make_fitness,
          function=_mean_square_error,
          greater_is_better="Sure",
      )
      assert_raises(
          ValueError,
          make_fitness,
          function=_mean_square_error,
          greater_is_better=1,
      )
      # non-bool wrap
      assert_raises(
          ValueError,
          make_fitness,
          function=_mean_square_error,
          greater_is_better=True,
          wrap="f",
      )
  
      # Check arg count tests
      def bad_fun1(x1, x2):
          return 1.0
  
      assert_raises(
          ValueError,
          make_fitness,
          function=bad_fun1,
          greater_is_better=True,
      )
  
      # Check return type tests
      def bad_fun2(x1, x2, w):
          return "ni"
  
      assert_raises(
          ValueError,
          make_fitness,
          function=bad_fun2,
          greater_is_better=True,
      )
  
      def _custom_metric(y, y_pred, w):
          """Calculate the root mean square error."""
          return np.sqrt(np.average(((y_pred - y) ** 2), weights=w))
  
      custom_metric = make_fitness(
          function=_custom_metric, greater_is_better=True
      )
  
      for Symbolic in (SymbolicRegressor, SymbolicTransformer):
          # These should be fine
          est = Symbolic(
              generations=2, random_state=0, metric=custom_metric
          )
          est.fit(diabetes.data, diabetes.target)
  
file_path: gplearn/gplearn/tests/test_fitness.py
imports: import pickle
  import numpy
  from sklearn.datasets import load_diabetes, load_breast_cancer
  from sklearn.metrics import mean_absolute_error
  from sklearn.utils._testing import assert_raises
  from sklearn.utils.validation import check_random_state
  from gplearn.genetic import SymbolicRegressor, SymbolicClassifier
  from gplearn.genetic import SymbolicTransformer
  from gplearn.fitness import make_fitness, _mean_square_error
label_desc: Use image node_id 1 for calling a global function with example usage: test_validate_fitness() and returns: int, str, np