code: def _buildAB(lap_sparse, labels):
      """Build the matrix A and rhs B of the linear system to solve.
  
      A and B are two block of the laplacian of the image graph.
      """
      labels = labels[labels >= 0]
      indices = np.arange(labels.size)
      unlabeled_indices = indices[labels == 0]
      seeds_indices = indices[labels > 0]
      # The following two lines take most of the time in this function
      B = lap_sparse[unlabeled_indices][:, seeds_indices]
      lap_sparse = lap_sparse[unlabeled_indices][:, unlabeled_indices]
      nlabels = labels.max()
      rhs = []
      for lab in range(1, nlabels + 1):
          mask = labels[seeds_indices] == lab
          fs = sparse.csr_matrix(mask)
          fs = fs.transpose()
          rhs.append(B * fs)
      return lap_sparse, rhs
  
file_path: nilearn/nilearn/_utils/segmentation.py
imports: import warnings
  import numpy
  from scipy import ndimage, sparse
  from scipy.sparse.linalg import cg
  from sklearn.utils import as_float_array
label_desc: Use image node_id 6 for calling a global function with example usage: _buildAB(lap_sparse, labels) and returns: lap_sparse,  rhs