code: def test_copy_and_restore_vals(data, pars):
      """Test functions to save and restore parameter values and stderrs."""
      # test copy_vals without/with stderr present
      copy_pars = lmfit.confidence.copy_vals(pars)
  
      assert isinstance(copy_pars, dict)
      for _, par in enumerate(pars):
          assert_allclose(pars[par].value, copy_pars[par][0])
          assert copy_pars[par][1] is None  # no stderr present
  
      minimizer = lmfit.Minimizer(residual, pars, fcn_args=(data))
      out = minimizer.leastsq()
      copy_pars_out = lmfit.confidence.copy_vals(out.params)
  
      assert isinstance(copy_pars_out, dict)
      for _, par in enumerate(out.params):
          assert_allclose(out.params[par].value, copy_pars_out[par][0])
          assert_allclose(out.params[par].stderr, copy_pars_out[par][1])
  
      # test restore_vals to the original parameter set after changing them first
      pars["a"].set(value=1.0)
      pars["b"].set(value=10)
      lmfit.confidence.restore_vals(copy_pars, pars)
  
      assert isinstance(pars, lmfit.parameter.Parameters)
      assert_allclose(pars["a"].value, 0.1)
      assert_allclose(pars["b"].value, 1.0)
      assert pars["a"].stderr is None
      assert pars["b"].stderr is None
  
      lmfit.confidence.restore_vals(copy_pars_out, pars)
      for _, par in enumerate(pars):
          assert_allclose(pars[par].value, out.params[par].value)
          assert_allclose(pars[par].stderr, out.params[par].stderr)
  
imports: import copy
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from scipy.stats import f
  import lmfit
label_desc: Use image node_id 5 for calling a global function with example usage: test_copy_and_restore_vals(data, pars) without return types