code: def check_fit(
      model,
      params,
      x,
      y,
      test_values,
      noise_scale=1.0e-3,
      atol=0.1,
      rtol=0.05,
  ):
      """Checks that a model fits noisy data well
  
      Parameters
      -----------
      model:  model to use
      par:  parameters to use
      x:      x data
      y:      y data
      test_values: dict of 'true values'
      noise_scale: float, optional
             The standard deviation of noise that is added to the test data.
      atol: float, optional
             Absolute tolerance for considering fit parameters close to the
             parameters test data was generated with.
      rtol: float, optional
             Relative tolerance for considering fit parameters close to the
             parameters test data was generated with.
  
      Returns
      -------
        fit result
  
      Raises
      -------
         AssertionError
            Any fit parameter that is not close to the parameter used to
            generate the test data raises this error.
      """
      y += np.random.normal(scale=noise_scale, size=len(y))
      result = model.fit(y, params, x=x)
      fit_values = result.best_values
      for name, test_val in test_values.items():
          _isclose(name, test_val, fit_values[name], atol, rtol)
      return result
  
file_path: lmfit-py/tests/test_models.py
imports: import numpy
  import lmfit
  from lmfit.lineshapes import gaussian
  from lmfit.models import GaussianModel, SplineModel
label_desc: Use image node_id 2 for calling a global function with example usage: check_fit(model, params, x, y, test_values, noise_scale, atol, rtol) and returns: result