code: def fast_find_nn_pre(ts, m):
      n = len(ts)
      X = np.fft.fft(ts)
      cum_sumx = np.cumsum(ts)
      cum_sumx2 = np.cumsum(np.power(ts, 2))
      sumx = cum_sumx[m - 1 : n] - np.insert(cum_sumx[0 : n - m], 0, 0)
      sumx2 = cum_sumx2[m - 1 : n] - np.insert(
          cum_sumx2[0 : n - m], 0, 0
      )
      meanx = sumx / m
      sigmax2 = (sumx2 / m) - np.power(meanx, 2)
      sigmax = np.sqrt(sigmax2)
  
      return (X, n, sumx2, sumx, meanx, sigmax2, sigmax)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import math
  import time
  import warnings
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: fast_find_nn_pre(ts, m) and returns: X,  n,  sumx2,  sumx,  meanx,  sigmax2,  sigmax