code: def stomp_ab(ts1, ts2, m):
      """STOMP implementation for AB similarity join.
  
      Parameters
      ----------
          ts1: numpy.array
              First time series.
          ts2: numpy.array
              Second time series.
          m: int
              Length of the subsequences.
  
      Output
      ------
          mp: numpy.array
              Array with the distance between every subsequence from ts1
              to the nearest subsequence with same length from ts2.
          ip: numpy.array
              Array with the index of the nearest neighbor of ts1 in ts2.
      """
      len1 = len(ts1)
      len2 = len(ts2)
  
      ts1 = ts1.flatten()
      ts2 = ts2.flatten()
  
      # Number of subsequences
      n_ts1_subs = len1 - m + 1
      n_ts2_subs = len2 - m + 1
  
      # Compute the mean and standard deviation
      ts1_mean = [np.mean(ts1[i : i + m]) for i in range(0, n_ts1_subs)]
      ts1_std = [np.std(ts1[i : i + m]) for i in range(0, n_ts1_subs)]
  
      ts2_mean = [np.mean(ts2[i : i + m]) for i in range(0, n_ts2_subs)]
      ts2_std = [np.std(ts2[i : i + m]) for i in range(0, n_ts2_subs)]
  
      # Compute the dot products between the first ts2 subsequence and every
      # ts1 subsequence
      dot_prod = sliding_dot_products(ts2[0:m], ts1, m, len1)
      first_dot_prod = np.copy(dot_prod)
  
      # Initialization
      mp = np.full(n_ts1_subs, float("inf"))  # matrix profile
      ip = np.zeros(n_ts1_subs)  # index profile
  
      # Compute the distance profile for the first ts1 subsequence
      dot_prod = sliding_dot_products(ts1[0:m], ts2, m, len2)
      dp = calculate_distance_profile(
          dot_prod,
          ts1_mean[0],
          ts1_std[0],
          ts2_mean,
          ts2_std,
          m,
          n_ts2_subs,
      )
  
      # Updates the matrix profile
      mp[0] = np.amin(dp)
      ip[0] = np.argmin(dp)
  
      for i in range(1, n_ts1_subs):
          for j in range(n_ts2_subs - 1, 0, -1):
              dot_prod[j] = (
                  dot_prod[j - 1]
                  - ts2[j - 1] * ts1[i - 1]
                  + ts2[j - 1 + m] * ts1[i - 1 + m]
              )  # compute the next dot products
              # using the previous ones
          dot_prod[0] = first_dot_prod[i]
          dp = calculate_distance_profile(
              dot_prod,
              ts1_mean[i],
              ts1_std[i],
              ts2_mean,
              ts2_std,
              m,
              n_ts2_subs,
          )
          mp[i] = np.amin(dp)
          ip[i] = np.argmin(dp)
  
      return mp, ip
  
imports: import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: stomp_ab(ts1, ts2, m) and returns: mp,  ip