code: def test_basinhopping_2d_lmfit_vs_scipy():
      """Test basinhopping in lmfit versus scipy."""
  
      # SciPy
      def func2d(x):
          return (
              np.cos(14.5 * x[0] - 0.3)
              + (x[1] + 0.2) * x[1]
              + (x[0] + 0.2) * x[0]
          )
  
      minimizer_kwargs = {"method": "L-BFGS-B"}
      x0 = [1.0, 1.0]
  
      ret = basinhopping(
          func2d, x0, minimizer_kwargs=minimizer_kwargs, seed=7
      )
  
      # lmfit
      def residual_2d(params):
          x0 = params["x0"].value
          x1 = params["x1"].value
          return (
              np.cos(14.5 * x0 - 0.3)
              + (x1 + 0.2) * x1
              + (x0 + 0.2) * x0
          )
  
      pars = lmfit.Parameters()
      pars.add_many(("x0", 1.0), ("x1", 1.0))
  
      mini = lmfit.Minimizer(residual_2d, pars)
      kws = {"minimizer_kwargs": {"method": "L-BFGS-B"}, "seed": 7}
      out = mini.minimize(method="basinhopping", **kws)
  
      assert_allclose(out.residual, ret.fun)
      assert_allclose(out.params["x0"].value, ret.x[0], rtol=1e-5)
      assert_allclose(out.params["x1"].value, ret.x[1], rtol=1e-5)
  
file_path: lmfit-py/tests/test_basinhopping.py
imports: import numpy
  from numpy.testing import assert_allclose
  import pytest
  from scipy.optimize import basinhopping
  import lmfit
label_desc: Use image node_id 2 for calling a global function with example usage: test_basinhopping_2d_lmfit_vs_scipy() and returns: unknown, unknown