code: def chi2(pars):
      """Cost function."""
      y_model = pars[0] * data["x"] + pars[1]
      chi = (data["y"] - y_model) / data["y_err"]
      return np.sum(chi**2)
  
imports: import numpy
  import pandas
  import statsmodels.api
  from scipy.optimize import curve_fit
  from scipy.optimize import minimize
label_desc: Use image node_id 2 for calling a global function with example usage: chi2(pars) and returns: np