code: def monotone_fn_inverter(fn, x, vectorized=True, **keywords):
      """
      Given a monotone function x (no checking is done to verify monotonicity)
      and a set of x values, return an linearly interpolated approximation
      to its inverse from its values on x.
      """
  
      if vectorized:
          y = fn(x, **keywords)
      else:
          y = []
          for _x in x:
              y.append(fn(_x, **keywords))
          y = np.array(y)
  
      a = np.argsort(y)
  
      return scipy.interpolate.interp1d(y[a], x[a])
  
file_path: nipy/nipy/algorithms/statistics/models/utils.py
imports: import numpy
  import scipy.interpolate
label_desc: Use image node_id 3 for calling a global function with example usage: monotone_fn_inverter(fn, x, vectorized) and returns: scipy