code: def acf(x, max_lag):
      """Autocorrelation function transform.
  
      currently calculated using standard stats method. We could use inverse of power
      spectrum, especially given we already have found it, worth testing for speed and
      correctness. HOWEVER, for long series, it may not give much benefit, as we do not
      use that many ACF terms.
  
      Parameters
      ----------
      x : array-like shape = [interval_width]
      max_lag: int
          The number of ACF terms to find.
  
      Returns
      -------
      y : array-like shape = [max_lag]
      """
      y = np.empty(max_lag)
      length = len(x)
      for lag in prange(1, max_lag + 1):
          # Do it ourselves to avoid zero variance warnings
          lag_length = length - lag
          x1, x2 = x[:-lag], x[lag:]
          s1 = np.sum(x1)
          s2 = np.sum(x2)
          m1 = s1 / lag_length
          m2 = s2 / lag_length
          ss1 = np.sum(x1 * x1)
          ss2 = np.sum(x2 * x2)
          v1 = ss1 - s1 * m1
          v2 = ss2 - s2 * m2
          v1_is_zero, v2_is_zero = v1 <= 1e-9, v2 <= 1e-9
          if v1_is_zero and v2_is_zero:  # Both zero variance,
              # so must be 100% correlated
              y[lag - 1] = 1
          elif v1_is_zero or v2_is_zero:  # One zero variance
              # the other not
              y[lag - 1] = 0
          else:
              y[lag - 1] = np.sum((x1 - m1) * (x2 - m2)) / np.sqrt(
                  v1 * v2
              )
          # _x = np.vstack((x[:-lag], x[lag:]))
          # s = np.sum(_x, axis=1)
          # ss = np.sum(_x * _x, axis=1)
          # v = ss - s * s / l
          # zero_variances = v <= 1e-9
          # i = lag - 1
          # if np.all(zero_variances):  # Both zero variance,
          #     # so must be 100% correlated
          #     y[i] = 1
          # elif np.any(zero_variances):  # One zero variance
          #     # the other not
          #     y[i] = 0
          # else:
          #     m = _x - s.reshape(2, 1) / l
          #     y[i] = (m[0] @ m[1]) / np.sqrt(np.prod(v))
  
      return y
  
imports: import numpy
  from sktime.utils.numba.njit import jit
  from sktime.utils.validation._dependencies import _check_soft_dependencies
label_desc: Use image node_id 1 for calling a global function with example usage: acf(x, max_lag) and returns: y