code: def rptree_leaf_array(rp_forest):
      
      if len(rp_forest) > 0:
          leaf_array = np.vstack([tree.indices for tree in rp_forest])
      else:
          leaf_array = np.array([[-1]])
  
      return leaf_array
docs: Generate an array of sets of candidate nearest neighbors by
      constructing a random projection forest and taking the leaves of all the
      trees. Any given tree has leaves that are a set of potential nearest
      neighbors. Given enough trees the set of all such leaves gives a good
      likelihood of getting a good set of nearest neighbors in composite. Since
      such a random projection forest is inexpensive to compute, this can be a
      useful means of seeding other nearest neighbor algorithms.
      Parameters
      ----------
      data: array of shape (n_samples, n_features)
          The data for which to generate nearest neighbor approximations.
      n_neighbors: int
          The number of nearest neighbors to attempt to approximate.
      rng_state: array of int64, shape (3,)
          The internal state of the rng
      n_trees: int (optional, default 10)
          The number of trees to build in the forest construction.
      angular: bool (optional, default False)
          Whether to use angular/cosine distance for random projection tree
          construction.
      Returns
      -------
      leaf_array: array of shape (n_leaves, max(10, n_neighbors))
          Each row of leaf array is a list of indices found in a given leaf.
          Since not all leaves are the same size the arrays are padded out with -1
          to ensure we can return a single ndarray.