code: def conf_interval2d(
      minimizer,
      result,
      x_name,
      y_name,
      nx=10,
      ny=10,
      limits=None,
      prob_func=None,
      nsigma=5,
      chi2_out=False,
  ):
      r"""Calculate confidence regions for two fixed parameters.
  
      The method itself is explained in `conf_interval`: here we are fixing
      two parameters.
  
      Parameters
      ----------
      minimizer : Minimizer
          The minimizer to use, holding objective function.
      result : MinimizerResult
          The result of running minimize().
      x_name : str
          The name of the parameter which will be the x direction.
      y_name : str
          The name of the parameter which will be the y direction.
      nx : int, optional
          Number of points in the x direction (default is 10).
      ny : int, optional
          Number of points in the y direction (default is 10).
      limits : tuple, optional
          Should have the form ``((x_upper, x_lower), (y_upper, y_lower))``.
          If not given, the default is nsigma*stderr in each direction.
      prob_func : None or callable, deprecated
          Starting with version 1.2, this argument is unused and has no effect.
      nsigma : float or int, optional
          Multiplier of stderr for limits (default is 5).
      chi2_out: bool
          Whether to return chi-square at each coordinate instead of probability.
  
      Returns
      -------
      x : numpy.ndarray
          X-coordinates (same shape as `nx`).
      y : numpy.ndarray
          Y-coordinates (same shape as `ny`).
      grid : numpy.ndarray
          2-D array (with shape ``(nx, ny)``) containing the calculated
          probabilities or chi-square.
  
      See Also
      --------
      conf_interval
  
      Examples
      --------
      >>> mini = Minimizer(some_func, params)
      >>> result = mini.leastsq()
      >>> x, y, gr = conf_interval2d(mini, result, 'para1','para2')
      >>> plt.contour(x,y,gr)
  
      """
      if prob_func is not None:
          msg = "'prob_func' has no effect and will be removed in version 1.4."
          raise DeprecationWarning(msg)
  
      params = result.params
  
      best_chisqr = result.chisqr
      redchi = result.redchi
      org = copy_vals(result.params)
  
      x = params[x_name]
      y = params[y_name]
  
      if limits is None:
          (x_upper, x_lower) = (
              x.value + nsigma * x.stderr,
              x.value - nsigma * x.stderr,
          )
          (y_upper, y_lower) = (
              y.value + nsigma * y.stderr,
              y.value - nsigma * y.stderr,
          )
      elif len(limits) == 2:
          (x_upper, x_lower) = limits[0]
          (y_upper, y_lower) = limits[1]
  
      x_points = np.linspace(x_lower, x_upper, nx)
      y_points = np.linspace(y_lower, y_upper, ny)
      grid = np.dstack(np.meshgrid(x_points, y_points))
  
      x.vary, y.vary = False, False
  
      def calc_chisqr(vals, restore=False):
          """Calculate chi-square for a set of parameter values."""
          save_x = x.value
          save_y = y.value
          result.params[x.name].value = vals[0]
          result.params[y.name].value = vals[1]
          minimizer.prepare_fit(params=result.params)
          out = minimizer.leastsq()
          result.params[x.name].value = save_x
          result.params[y.name].value = save_y
          return out.chisqr
  
      # grid of chi-square
      out_mat = np.apply_along_axis(calc_chisqr, -1, grid)
  
      # compute grid of sigma values from chi-square
      if not chi2_out:
          chisqr0 = out_mat.min()
          chisqr0 = min(best_chisqr, chisqr0)
          out_mat = np.sqrt((out_mat - chisqr0) / redchi)
  
      x.vary, y.vary = True, True
      restore_vals(org, result.params)
      result.chisqr = best_chisqr
      return x_points, y_points, out_mat
  
file_path: lmfit-py/lmfit/confidence.py
imports: from warnings import warn
  import numpy
  from scipy.optimize import root_scalar
  from scipy.special import erf
  from scipy.stats import f
  from .minimizer import MinimizerException
label_desc: Use image node_id 6 for calling a global function with example usage: conf_interval2d(minimizer, result, x_name, y_name, nx, ny, limits, prob_func, nsigma, chi2_out) and returns: x_points,  y_points,  out_mat, out