code: def objective(params, x, data):
      """calculate total residual for fits to several data sets held
      in a 2-D array, and modeled by Gaussian functions"""
      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 numpy
  from lmfit import Parameters, minimize
  from lmfit.lineshapes import gaussian
label_desc: Use image node_id 2 for calling a global function with example usage: objective(params, x, data) and returns: resid