code: def convert_tree_format(tree, data_size, data_dim):
      n_nodes, n_leaves = num_nodes_and_leaves(tree)
      is_sparse = False
      if tree.hyperplanes[0].ndim == 1:
          # dense hyperplanes
          hyperplane_dim = data_dim
          hyperplanes = np.zeros(
              (n_nodes, hyperplane_dim), dtype=np.float32
          )
      else:
          # sparse hyperplanes
          is_sparse = True
          hyperplane_dim = data_dim
          hyperplanes = np.zeros(
              (n_nodes, 2, hyperplane_dim), dtype=np.float32
          )
          hyperplanes[:, 0, :] = -1
  
      offsets = np.zeros(n_nodes, dtype=np.float32)
      children = np.int32(-1) * np.ones((n_nodes, 2), dtype=np.int32)
      indices = np.int32(-1) * np.ones(data_size, dtype=np.int32)
      if is_sparse:
          recursive_convert_sparse(
              tree,
              hyperplanes,
              offsets,
              children,
              indices,
              0,
              0,
              len(tree.children) - 1,
          )
      else:
          recursive_convert(
              tree,
              hyperplanes,
              offsets,
              children,
              indices,
              0,
              0,
              len(tree.children) - 1,
          )
      return FlatTree(
          hyperplanes, offsets, children, indices, tree.leaf_size
      )
  
imports: from warnings import warn
  import locale
  import numpy
  import numba
  import scipy.sparse
  from pynndescent.sparse import sparse_mul, sparse_diff, sparse_sum, arr_intersect, sparse_dot_product
  from pynndescent.utils import tau_rand_int, norm
  import joblib
  from collections import namedtuple
label_desc: Use image node_id 22 for calling a global function with example usage: convert_tree_format(tree, data_size, data_dim) and returns: FlatTree