code: def linear_chisq(params, x, data, errs=None):
      """Calculates chi-squared residuals for linear model."""
      if not isinstance(params, lmfit.parameter.Parameters):
          msg = "Params argument is not a lmfit parameter set"
          raise TypeError(msg)
  
      if "m" not in params.keys():
          msg = "No slope parameter (m) defined in the model"
          raise KeyError(msg)
  
      if "c" not in params.keys():
          msg = "No intercept parameter (c) defined in the model"
          raise KeyError(msg)
  
      model = params["m"] * x + params["c"]
      residuals = data - model
      if errs is not None:
          residuals = residuals / errs
  
      return residuals
  
imports: import numpy
  from numpy.testing import assert_allclose
  import lmfit
label_desc: Use image node_id 1 for calling a global function with example usage: linear_chisq(params, x, data, errs) and returns: residuals