code: def _ft_acf(
      name: str,
      fun: Callable,
      data: pd.Series,
      n_diff: Tuple[int, ...],
      n_size: Tuple[int, ...],
  ) -> pd.Series:
      freq = freq_to_period(data.index.inferred_freq) or 1
      ret = {}
      for n_diff_ in n_diff:
          datadiff = np.diff(data.values, n=n_diff_)
          max_lags = len(datadiff) // 2 - 1 if name == "pacf" else None
          ts = _acf(fun, datadiff, freq=freq, max_lags=max_lags)
          if n_diff_ == 0:
              ret[f"{name}(season)"] = (
                  ts[freq] if len(ts) > freq else np.nan
              )
          for n_size_ in n_size:
              ts_acf = ts[1 : 1 + n_size_]
              val = (np.square(ts_acf) if n_size_ > 1 else ts_acf).sum()
              ret[f"{name}{n_size_}(d={n_diff_})"] = val
      return pd.Series(ret)
  
imports: from typing import Optional, Callable, Union, Tuple
  from functools import partial
  import warnings
  import numpy
  import pandas
  from scipy.signal import welch
  from statsmodels.tsa.seasonal import STL
  from statsmodels.tsa.stattools import acf, pacf, kpss, adfuller
  from statsmodels.tsa.tsatools import freq_to_period
  from .None import _supsmu
  from tslumen.profile.base import ProfilingFunction
label_desc: Use image node_id 5 for calling a global function with example usage: _ft_acf(name, fun, data, n_diff, n_size) and returns: pd