code: def find_nearest(a, value, index=False):
      
      i = np.abs(a - value).argmin()
      if index:
          return i
      else:
          return a[i]
docs: Find the array value, or index of the array value, closest to some given
      value.
  
      Args:
          a (ndarray)
          value (float)
          index (bool): whether to return the index instead of the array value.
  
      Returns:
          float. The array value (or index, as int) nearest the specified value.