code: def _mean_depth_custom_tree(custom_tree_, X, feature_costs):
      node = custom_tree_.root
      n_samples = []
      cum_costs = []
      is_leaves = []
      stack = [(node, 0)]
      while len(stack) > 0:
          node, cost = stack.pop()
          n_samples.append(node.num_samples)
          cum_costs.append(cost)
          is_leaves.append(node.left is None and node.right is None)
  
          if node.left:
              stack.append(
                  (node.left, cost + feature_costs[node.feature_index])
              )
          if node.right:
              stack.append(
                  (node.right, cost + feature_costs[node.feature_index])
              )
      is_leaves = np.array(is_leaves)
      cum_costs = np.array(cum_costs)[is_leaves]
      n_samples = np.array(n_samples)[is_leaves]
      costs = cum_costs * n_samples / np.sum(n_samples)
      return np.sum(costs)
  
file_path: imodels/imodels/util/tree.py
imports: from sklearn import datasets
  from sklearn.tree import DecisionTreeRegressor
  import numpy
  from sklearn.tree._tree import Tree
  from imodels.tree.custom_greedy_tree import CustomDecisionTreeClassifier
label_desc: Use image node_id 4 for calling a global function with example usage: _mean_depth_custom_tree(custom_tree_, X, feature_costs) and returns: np