code: def find_ijv_overlaps(parent_ijv, child_ijv, validate=True):
      """
      Find per pixel overlap of parent labels and child labels
  
      'parent_ijv' - the parents which contain the children, in 'ijv' format
      'child_ijv' - the children to be mapped to a parent, in 'ijv' format
  
      Returns a sparse 'csc_matrix' of overlap between each parent and child.
      Note that the first row and column are empty, as these
      correspond to parent and child labels of 0.
      """
      if validate:
          _validate_ijv(parent_ijv)
          _validate_ijv(child_ijv)
  
      parent_count = (
          0 if (parent_ijv.shape[0] == 0) else np.max(parent_ijv[:, 2])
      )
      child_count = (
          0 if (child_ijv.shape[0] == 0) else np.max(child_ijv[:, 2])
      )
  
      if parent_count == 0 or child_count == 0:
          return np.zeros((parent_count + 1, child_count + 1), int)
  
      dim_i = max(np.max(parent_ijv[:, 0]), np.max(child_ijv[:, 0])) + 1
      dim_j = max(np.max(parent_ijv[:, 1]), np.max(child_ijv[:, 1])) + 1
      parent_linear_ij = parent_ijv[:, 0] + dim_i * parent_ijv[
          :, 1
      ].astype(np.uint64)
      child_linear_ij = child_ijv[:, 0] + dim_i * child_ijv[
          :, 1
      ].astype(np.uint64)
  
      parent_matrix = scipy.sparse.coo_matrix(
          (
              np.ones((parent_ijv.shape[0],)),
              (parent_ijv[:, 2], parent_linear_ij),
          ),
          shape=(parent_count + 1, dim_i * dim_j),
      )
      child_matrix = scipy.sparse.coo_matrix(
          (
              np.ones((child_ijv.shape[0],)),
              (child_linear_ij, child_ijv[:, 2]),
          ),
          shape=(dim_i * dim_j, child_count + 1),
      )
      # I surely do not understand the sparse code.  Converting both
      # arrays to csc gives the best peformance... Why not p.csr and
      # c.csc?
      return parent_matrix.tocsc() * child_matrix.tocsc()
  
imports: from enum import Enum
  import numpy
  from numpy.random.mtrand import RandomState
  import scipy.sparse
  import centrosome.index
label_desc: Use image node_id 25 for calling a global function with example usage: find_ijv_overlaps(parent_ijv, child_ijv, validate) and returns: unknown, np