code: def sparse_wasserstein_1d(ind1, data1, ind2, data2, p=1):
      result = 0.0
      old_ind = 0
      delta = 0.0
      i1 = 0
      i2 = 0
      cdf1 = 0.0
      cdf2 = 0.0
      l1_norm_x = np.sum(data1)
      l1_norm_y = np.sum(data2)
  
      norm = lambda x, p: np.power(np.abs(x), p)
  
      # pass through both index lists
      while i1 < ind1.shape[0] and i2 < ind2.shape[0]:
          j1 = ind1[i1]
          j2 = ind2[i2]
  
          if j1 == j2:
              result += delta * (j1 - old_ind)
              cdf1 += data1[i1] / l1_norm_x
              cdf2 += data2[i2] / l1_norm_y
              delta = norm(cdf1 - cdf2, p)
              old_ind = j1
              i1 += 1
              i2 += 1
          elif j1 < j2:
              result += delta * (j1 - old_ind)
              cdf1 += data1[i1] / l1_norm_x
              delta = norm(cdf1 - cdf2, p)
              old_ind = j1
              i1 += 1
          else:
              result += delta * (j2 - old_ind)
              cdf2 += data2[i2] / l1_norm_y
              delta = norm(cdf1 - cdf2, p)
              old_ind = j2
              i2 += 1
              # pass over the tails
      while i1 < ind1.shape[0]:
          j1 = ind1[i1]
          result += delta * (j1 - old_ind)
          cdf1 += data1[i1] / l1_norm_x
          delta = norm(cdf1 - cdf2, p)
          old_ind = j1
          i1 += 1
  
      while i2 < ind2.shape[0]:
          j2 = ind2[i2]
          result += delta * (j2 - old_ind)
          cdf2 += data2[i2] / l1_norm_y
          delta = norm(cdf1 - cdf2, p)
          old_ind = j2
          i2 += 1
  
      return np.power(result, 1.0 / p)
  
imports: from __future__ import print_function
  import locale
  import numpy
  import numba
  from pynndescent.utils import norm, tau_rand
  from pynndescent.distances import kantorovich, jensen_shannon_divergence, symmetric_kl_divergence
label_desc: Use image node_id 41 for calling a global function with example usage: sparse_wasserstein_1d(ind1, data1, ind2, data2, p) and returns: np