code: def make_masks(cluster_matrix):
      """Builds a sparse CSR mask matrix from the given clustering.
  
      This function is optimized since trees for images can be very large.
      """
  
      M = cluster_matrix.shape[0] + 1
      indices_row_pos = np.zeros(2 * M - 1, dtype=int)
      indptr = np.zeros(2 * M, dtype=int)
      indices = np.zeros(
          int(np.sum(cluster_matrix[:, 3])) + M, dtype=int
      )
  
      # build an array of index lists in CSR format
      _init_masks(cluster_matrix, M, indices_row_pos, indptr)
      _rec_fill_masks(
          cluster_matrix,
          indices_row_pos,
          indptr,
          indices,
          M,
          cluster_matrix.shape[0] - 1 + M,
      )
      mask_matrix = scipy.sparse.csr_matrix(
          (np.ones(len(indices), dtype=bool), indices, indptr),
          shape=(2 * M - 1, M),
      )
  
      return mask_matrix
  
imports: import copy
  import numpy
  import scipy.sparse
  from numba import njit
  from ..None import links
label_desc: Use image node_id 7 for calling a global function with example usage: make_masks(cluster_matrix) and returns: mask_matrix