code: def generate_leaf_updates(
      leaf_block, dist_thresholds, inds, indptr, data, dist
  ):
      updates = [[(-1, -1, np.inf)] for i in range(leaf_block.shape[0])]
  
      for n in numba.prange(leaf_block.shape[0]):
          for i in range(leaf_block.shape[1]):
              p = leaf_block[n, i]
              if p < 0:
                  break
  
              for j in range(i + 1, leaf_block.shape[1]):
                  q = leaf_block[n, j]
                  if q < 0:
                      break
  
                  from_inds = inds[indptr[p] : indptr[p + 1]]
                  from_data = data[indptr[p] : indptr[p + 1]]
  
                  to_inds = inds[indptr[q] : indptr[q + 1]]
                  to_data = data[indptr[q] : indptr[q + 1]]
                  d = dist(from_inds, from_data, to_inds, to_data)
  
                  if d < dist_thresholds[p] or d < dist_thresholds[q]:
                      updates[n].append((p, q, d))
  
      return updates
  
file_path: pynndescent/pynndescent/sparse_nndescent.py
imports: from __future__ import print_function
  import locale
  import numpy
  import numba
  from pynndescent.utils import tau_rand_int, make_heap, new_build_candidates, deheap_sort, checked_flagged_heap_push, apply_graph_updates_high_memory, apply_graph_updates_low_memory
  from pynndescent.sparse import sparse_euclidean
label_desc: Use image node_id 1 for calling a global function with example usage: generate_leaf_updates(leaf_block, dist_thresholds, inds, indptr, data, dist) and returns: updates