code: def nearest(x, y, new_x):
      """
      Rounds each new x to nearest input x and returns corresponding input y.
  
      Parameters
      ----------
      x : array_like
          Independent values.
      y : array_like
          Dependent values.
      new_x : array_like
          The x values to return the interpolate y values.
  
      Returns
      -------
      nearest : ndarray
          Rounds each `new_x` to nearest `x` and returns the corresponding `y`.
  
      """
      shifted_x = np.concatenate((np.array([x[0] - 1]), x[0:-1]))
  
      midpoints_of_x = atleast_1d_and_contiguous(0.5 * (x + shifted_x))
      new_x = atleast_1d_and_contiguous(new_x)
  
      TINY = 1e-10
      indices = np.searchsorted(midpoints_of_x, new_x + TINY) - 1
      indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(int))
      new_y = np.take(y, indices, axis=-1)
  
      return new_y
  
file_path: catboost/contrib/python/scipy/py2/scipy/interpolate/interpolate_wrapper.py
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from .None import _interpolate
label_desc: Use image node_id 2 for calling a global function with example usage: nearest(x, y, new_x) and returns: new_y