code: def apply_update_positions(
      matrix_profile,
      mp_index,
      refine_distance,
      beginidx,
      endidx,
      orig_index,
      idx_diff,
  ):
      tmp_a = refine_distance[beginidx : endidx + 1]
      tmp_b = matrix_profile[beginidx : endidx + 1]
      update_pos1 = np.argwhere(tmp_a < tmp_b).flatten()
  
      if len(update_pos1) > 0:
          update_pos1 = update_pos1 + beginidx
          matrix_profile[update_pos1] = refine_distance[update_pos1]
          mp_index[update_pos1] = orig_index[update_pos1] + idx_diff
  
      tmp_a = refine_distance[beginidx : endidx + 1]
      tmp_b = matrix_profile[
          beginidx + idx_diff : endidx + idx_diff + 1
      ]
      update_pos2 = np.argwhere(tmp_a < tmp_b).flatten()
  
      if len(update_pos2) > 0:
          update_pos2 = update_pos2 + beginidx
          matrix_profile[update_pos2 + idx_diff] = refine_distance[
              update_pos2
          ]
          mp_index[update_pos2 + idx_diff] = orig_index[update_pos2]
  
      return (matrix_profile, mp_index)
  
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 19 for calling a global function with example usage: apply_update_positions(matrix_profile, mp_index, refine_distance, beginidx, endidx, orig_index, idx_diff) and returns: matrix_profile,  mp_index