code: def test_validate_function():
      """Check that valid functions are accepted & invalid ones raise error"""
  
      # Check arity tests
      _ = make_function(function=_protected_sqrt, name="sqrt", arity=1)
      # non-integer arity
      assert_raises(
          ValueError,
          make_function,
          function=_protected_sqrt,
          name="sqrt",
          arity="1",
      )
      assert_raises(
          ValueError,
          make_function,
          function=_protected_sqrt,
          name="sqrt",
          arity=1.0,
      )
      # non-bool wrap
      assert_raises(
          ValueError,
          make_function,
          function=_protected_sqrt,
          name="sqrt",
          arity=1,
          wrap="f",
      )
      # non-matching arity
      assert_raises(
          ValueError,
          make_function,
          function=_protected_sqrt,
          name="sqrt",
          arity=2,
      )
      assert_raises(
          ValueError,
          make_function,
          function=maximum,
          name="max",
          arity=1,
      )
  
      # Check name test
      assert_raises(
          ValueError,
          make_function,
          function=_protected_sqrt,
          name=2,
          arity=1,
      )
  
      # Check return type tests
      def bad_fun1(x1, x2):
          return "ni"
  
      assert_raises(
          ValueError,
          make_function,
          function=bad_fun1,
          name="ni",
          arity=2,
      )
  
      # Check return shape tests
      def bad_fun2(x1):
          return np.ones((2, 1))
  
      assert_raises(
          ValueError,
          make_function,
          function=bad_fun2,
          name="ni",
          arity=1,
      )
  
      # Check closure for negatives test
      def _unprotected_sqrt(x1):
          with np.errstate(divide="ignore", invalid="ignore"):
              return np.sqrt(x1)
  
      assert_raises(
          ValueError,
          make_function,
          function=_unprotected_sqrt,
          name="sqrt",
          arity=1,
      )
  
      # Check closure for zeros test
      def _unprotected_div(x1, x2):
          with np.errstate(divide="ignore", invalid="ignore"):
              return np.divide(x1, x2)
  
      assert_raises(
          ValueError,
          make_function,
          function=_unprotected_div,
          name="div",
          arity=2,
      )
  
file_path: gplearn/gplearn/tests/test_functions.py
imports: import pickle
  import numpy
  from numpy import maximum
  from sklearn.datasets import load_diabetes, load_breast_cancer
  from sklearn.utils._testing import assert_raises
  from sklearn.utils.validation import check_random_state
  from gplearn.functions import _protected_sqrt, make_function
  from gplearn.genetic import SymbolicRegressor, SymbolicTransformer
  from gplearn.genetic import SymbolicClassifier
label_desc: Use image node_id 1 for calling a global function with example usage: test_validate_function() and returns: str, np, np, np