code: def test_nested_solver(nested, solver):
      from mystic.monitors import Monitor
  
      evalmon = Monitor()
      stepmon = Monitor()
  
      from mystic.math.measures import mean, spread
  
      @with_spread(5.0)
      @with_mean(5.0)
      def constraints(x):
          return x
  
      def cost(x):
          return abs(sum(x) - 5.0)
  
      from numpy import array
  
      nested = nested(5, 4)
      nested.SetEvaluationMonitor(evalmon)
      nested.SetGenerationMonitor(stepmon)
      nested.SetConstraints(constraints)
      nested.SetNestedSolver(solver)
      nested.Solve(cost, disp=False)
      y = nested.Solution()
  
      assert almostEqual(mean(y), 5.0, tol=1e-15)
      assert almostEqual(spread(y), 5.0, tol=1e-15)
      assert almostEqual(cost(y), 4 * (5.0), tol=1e-6)
  
file_path: mystic/mystic/tests/test_solver_constraints.py
imports: from mystic.constraints import *
  from mystic.solvers import *
  from mystic.math import almostEqual
  from mystic.tools import random_seed
label_desc: Use image node_id 3 for calling a global function with example usage: test_nested_solver(nested, solver) and returns: x, abs