code: def _diff_transform(
      X: Union[pd.Series, pd.DataFrame], lags: np.array
  ):
      """Perform differencing on Series or DataFrame.
  
      Parameters
      ----------
      X : pd.DataFrame
      lags : int or iterable of int, e.g., list of int
  
      Returns
      -------
      `X` differenced at lags `lags`, always a copy (no reference)
      if `lags` is int, applies diff to X at period `lags`
          returns X.diff(periods=lag)
      if `lags` is list of int, loops over elements from start to end
          and applies diff to X at period lags[value], for value in the list `lags`
      """
      if isinstance(lags, int):
          lags = [lags]
  
      Xt = X
  
      for lag in lags:
          # converting lag to int since pandas complains if it's np.int64
          Xt = Xt.diff(periods=int(lag))
  
      return Xt
  
imports: from typing import Union
  import numpy
  import pandas
  from sklearn.utils import check_array
  from sktime.datatypes._utilities import get_cutoff, update_data
  from sktime.transformations.base import BaseTransformer
  from sktime.utils.validation import is_int
label_desc: Use image node_id 2 for calling a global function with example usage: _diff_transform(X, lags) and returns: Xt