code: def diff_inv(x, lag=1, differences=1, xi=None):
      """
      Inverse the difference of an array.
  
      A python implementation of the R ``diffinv`` function [1]. This computes
      the inverse of lag differences from an array given a ``lag``
      and ``differencing`` term.
  
      If ``x`` is a vector of length :math:`n`, ``lag=1`` and ``differences=1``,
      then the computed result is equal to the cumulative sum plus left-padding
      of zeros equal to ``lag * differences``.
  
      Examples
      --------
      Where ``lag=1`` and ``differences=1``:
  
      >>> x = c(10, 4, 2, 9, 34)
      >>> diff_inv(x, 1, 1)
      array([ 0., 10., 14., 16., 25., 59.])
  
      Where ``lag=1`` and ``differences=2``:
  
      >>> x = c(10, 4, 2, 9, 34)
      >>> diff_inv(x, 1, 2)
      array([  0.,   0.,  10.,  24.,  40.,  65., 124.])
  
      Where ``lag=3`` and ``differences=1``:
  
      >>> x = c(10, 4, 2, 9, 34)
      >>> diff_inv(x, 3, 1)
      array([ 0.,  0.,  0., 10.,  4.,  2., 19., 38.])
  
      Where ``lag=6`` (larger than the array is) and ``differences=1``:
  
      >>> x = c(10, 4, 2, 9, 34)
      >>> diff_inv(x, 6, 1)
      array([ 0.,  0.,  0.,  0.,  0.,  0., 10.,  4.,  2.,  9., 34.])
  
      For a 2d array with ``lag=1`` and ``differences=1``:
  
      >>> import numpy as np
      >>>
      >>> x = np.arange(1, 10).reshape((3, 3)).T
      >>> diff_inv(x, 1, 1)
      array([[ 0.,  0.,  0.],
             [ 1.,  4.,  7.],
             [ 3.,  9., 15.],
             [ 6., 15., 24.]])
  
      Parameters
      ----------
      x : array-like, shape=(n_samples, [n_features])
          The array to difference.
  
      lag : int, optional (default=1)
          An integer > 0 indicating which lag to use.
  
      differences : int, optional (default=1)
          An integer > 0 indicating the order of the difference.
  
      Returns
      -------
      res : np.ndarray, shape=(n_samples, [n_features])
          The result of the inverse of the difference arrays.
  
      References
      ----------
      .. [1] https://stat.ethz.ch/R-manual/R-devel/library/stats/html/diffinv.html
      """  # noqa: E501
      x = skval.check_array(
          x,
          dtype=DTYPE,
          copy=False,
          force_all_finite=False,
          ensure_2d=False,
      )
  
      # R code: if (lag < 1L || differences < 1L)
      # R code: stop ("bad value for 'lag' or 'differences'")
      if any(v < 1 for v in (lag, differences)):
          raise ValueError(
              "lag and differences must be positive (> 0) integers"
          )
  
      if x.ndim == 1:
          return _diff_inv_vector(x, lag, differences, xi)
      elif x.ndim == 2:
          return _diff_inv_matrix(x, lag, differences, xi)
      raise ValueError(
          "only vector and matrix inverse differencing " "are supported"
      )
  
file_path: pmdarima/pmdarima/utils/array.py
imports: from sklearn.utils import validation
  import numpy
  import pandas
  from ..compat import DTYPE
  from ._array import C_intgrt_vec
label_desc: Use image node_id 10 for calling a global function with example usage: diff_inv(x, lag, differences, xi) and returns: _diff_inv_vector, _diff_inv_matrix