code: def _PD_PeriodicityWang_th0_01(X):
      # Periodicity measure of (Wang et al. 2007).
      y_spline = _spline_fit(X)
  
      y_sub = np.zeros(len(X))
      for i in range(len(X)):
          y_sub[i] = X[i] - y_spline[i]
  
      acmax = int(np.ceil(len(X) / 3.0))
      acf = np.zeros(acmax)
      for tau in range(1, acmax + 1):
          covariance = 0
          for i in range(len(X) - tau):
              covariance += y_sub[i] * y_sub[i + tau]
          acf[tau - 1] = covariance / (len(X) - tau)
  
      troughs = np.zeros(acmax, dtype=np.int32)
      peaks = np.zeros(acmax, dtype=np.int32)
      n_troughs = 0
      n_peaks = 0
      for i in range(1, acmax - 1):
          slope_in = acf[i] - acf[i - 1]
          slope_out = acf[i + 1] - acf[i]
  
          if slope_in < 0 and slope_out > 0:
              troughs[n_troughs] = i
              n_troughs += 1
          elif slope_in > 0 and slope_out < 0:
              peaks[n_peaks] = i
              n_peaks += 1
  
      out = 0
      for i in range(n_peaks):
          j = -1
          while troughs[j + 1] < peaks[i] and j + 1 < n_troughs:
              j += 1
  
          if (
              j == -1
              or acf[peaks[i]] - acf[troughs[j]] < 0.01
              or acf[peaks[i]] < 0
          ):
              continue
  
          out = peaks[i]
          break
  
      return out
  
imports: import math
  import numpy
  from sktime.utils.numba.njit import njit
label_desc: Use image node_id 36 for calling a global function with example usage: _PD_PeriodicityWang_th0_01(X) and returns: out