code: def approx(
      x,
      y,
      xout,
      method="linear",
      rule=1,
      f=0,
      yleft=None,
      yright=None,
      ties="mean",
  ):
      """Linearly interpolate points.
  
      Return a list of points which (linearly) interpolate given data points,
      or a function performing the linear (or constant) interpolation.
  
      Parameters
      ----------
      x : array-like, shape=(n_samples,)
          Numeric vector giving the coordinates of the points
          to be interpolated.
  
      y : array-like, shape=(n_samples,)
          Numeric vector giving the coordinates of the points
          to be interpolated.
  
      xout : int, float or iterable
          A scalar or iterable of numeric values specifying where
          interpolation is to take place.
  
      method : str, optional (default='linear')
          Specifies the interpolation method to be used.
          Choices are "linear" or "constant".
  
      rule : int, optional (default=1)
          An integer describing how interpolation is to take place
          outside the interval ``[min(x), max(x)]``. If ``rule`` is 1 then
          np.nans are returned for such points and if it is 2, the value at the
          closest data extreme is used.
  
      f : int, optional (default=0)
          For ``method`` = "constant" a number between 0 and 1 inclusive,
          indicating a compromise between left- and right-continuous step
          functions. If y0 and y1 are the values to the left and right of the
          point then the value is y0 if f == 0, y1 if f == 1, and y0*(1-f)+y1*f
          for intermediate values. In this way the result is right-continuous
          for f == 0 and left-continuous for f == 1, even for non-finite
          ``y`` values.
  
      yleft : float, optional (default=None)
          The value to be returned when input ``x`` values are less than
          ``min(x)``. The default is defined by the value of rule given below.
  
      yright : float, optional (default=None)
          The value to be returned when input ``x`` values are greater than
          ``max(x)``. The default is defined by the value of rule given below.
  
      ties : str, optional (default='mean')
          Handling of tied ``x`` values. Choices are "mean" or "ordered".
      """
      if method not in VALID_APPROX:
          raise ValueError("method must be one of %r" % VALID_APPROX)
  
      # make sure xout is an array
      xout = c(xout).astype(np.float64)  # ensure double
  
      # check method
      method_key = method
  
      # not a callable, actually, but serves the purpose..
      method = get_callable(method_key, VALID_APPROX)
  
      # copy/regularize vectors
      x, y = _regularize(x, y, ties)
      nx = x.shape[0]
  
      # if len 1? (we've already handled where the size is 0, since we check that
      # in the _regularize function when we call c1d)
      if nx == 1:
          if method_key == "linear":
              raise ValueError(
                  "need at least two points to " "linearly interpolate"
              )
  
      # get yleft, yright
      if yleft is None:
          yleft = y[0] if rule != 1 else np.nan
      if yright is None:
          yright = y[-1] if rule != 1 else np.nan
  
      # call the C subroutine
      yout = C_Approx(
          x, y, xout, method, f, yleft, yright
      )  # MemoryView
      return xout, np.asarray(yout)
  
imports: import numpy
  from ..utils.array import c, check_endog
  from ..utils import get_callable
  from ..compat.numpy import DTYPE
  from pmdarima.arima._arima import C_Approx
label_desc: Use image node_id 2 for calling a global function with example usage: approx(x, y, xout, method, rule, f, yleft, yright, ties) and returns: xout,  np