code: def objective(params, x, data):
      """Calculate total residual for fits of Gaussians to several data sets."""
      ndata, _ = data.shape
      resid = 0.0 * data[:]
  
      # make residual per data set
      for i in range(ndata):
          resid[i, :] = data[i, :] - gauss_dataset(params, i, x)
  
      # now flatten this to a 1D array, as minimize() needs
      return resid.flatten()
  
imports: import matplotlib.pyplot
  import numpy
  from lmfit import Parameters, minimize, report_fit
label_desc: Use image node_id 3 for calling a global function with example usage: objective(params, x, data) and returns: resid