code: def test_minimize(self, maxiter, func_and_init):
      func, x0 = func_and_init
  
      @jit
      def min_op(x0):
          result = jax.scipy.optimize.minimize(
              func(jnp),
              x0,
              method="l-bfgs-experimental-do-not-rely-on-this",
              options=dict(maxiter=maxiter, gtol=1e-7),
          )
          return result.x
  
      jax_res = min_op(x0)
  
      # Newer scipy versions perform poorly in float32. See
      # https://github.com/scipy/scipy/issues/19024.
      x0_f64 = x0.astype("float64")
      # Note that without bounds, L-BFGS-B is just L-BFGS
      with jtu.ignore_warning(
          category=DeprecationWarning,
          message=".*tostring.*is deprecated.*",
      ):
          scipy_res = scipy.optimize.minimize(
              func(np), x0_f64, method="L-BFGS-B"
          ).x
  
      if func.__name__ == "matyas":
          # scipy performs badly for Matyas, compare to true minimum instead
          self.assertAllClose(
              jax_res, jnp.zeros_like(jax_res), atol=1e-7
          )
          return
  
      if func.__name__ == "eggholder":
          # L-BFGS performs poorly for the eggholder function.
          # Neither scipy nor jax find the true minimum, so we can only loosely (with high atol) compare the false results
          self.assertAllClose(jax_res, scipy_res, atol=1e-3)
          return
  
      self.assertAllClose(
          jax_res, scipy_res, atol=2e-5, check_dtypes=False
      )
  
imports: from absl.testing import absltest
  import numpy
  import scipy
  import scipy.optimize
  from jax import numpy
  from jax._src import test_util
  from jax import jit
  from jax import config
  import jax.scipy.optimize
label_desc: Use image node_id 1 for calling the TestLBFGS obj's underlying member method code with example usage: obj.test_minimize(maxiter, func_and_init) and returns: result