code: def test_multiple_constraints():
      def target_function(x, y):
          return np.cos(2 * x) * np.cos(y) + np.sin(x)
  
      def constraint_function_2_dim(x, y):
          return np.array(
              [
                  -np.cos(x) * np.cos(y) + np.sin(x) * np.sin(y),
                  -np.cos(x) * np.cos(-y) + np.sin(x) * np.sin(-y),
              ]
          )
  
      constraint_limit_lower = np.array([-np.inf, -np.inf])
      constraint_limit_upper = np.array([0.6, 0.6])
  
      conmod = NonlinearConstraint(
          constraint_function_2_dim,
          constraint_limit_lower,
          constraint_limit_upper,
      )
      pbounds = {"x": (0, 6), "y": (0, 6)}
  
      optimizer = BayesianOptimization(
          f=target_function,
          constraint=conmod,
          pbounds=pbounds,
          verbose=0,
          random_state=1,
      )
  
      optimizer.maximize(
          init_points=2,
          n_iter=10,
      )
  
      constraint_at_max = constraint_function_2_dim(
          **optimizer.max["params"]
      )
      assert np.all(
          (constraint_at_max <= constraint_limit_upper)
          & (constraint_at_max >= constraint_limit_lower)
      )
  
      params = optimizer.res[0]["params"]
      x, y = params["x"], params["y"]
  
      assert constraint_function_2_dim(x, y) == approx(
          optimizer.constraint.approx(np.array([x, y])),
          rel=1e-3,
          abs=1e-3,
      )
  
file_path: BayesianOptimization/tests/test_constraint.py
imports: import numpy
  from bayes_opt import BayesianOptimization
  from pytest import approx, raises
  from scipy.optimize import NonlinearConstraint
label_desc: Use image node_id 4 for calling a global function with example usage: test_multiple_constraints() and returns: unknown, np