code: def dectree_max_depth(tree):
      """
      Return the max depth of this tree in terms of how many nodes; a single
      root node gives height 1.
      """
      children_left = tree.children_left
      children_right = tree.children_right
  
      def walk(node_id):
          if (
              children_left[node_id] != children_right[node_id]
          ):  # decision node
              left_max = 1 + walk(children_left[node_id])
              right_max = 1 + walk(children_right[node_id])
              return max(left_max, right_max)
          else:  # leaf
              return 1
  
      root_node_id = 0
      return walk(root_node_id)
  
imports: import pandas
  import numpy
  import matplotlib.pyplot
  import sklearn
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.ensemble import RandomForestRegressor
  from distutils.version import LooseVersion
  from sklearn.model_selection import cross_val_score
  from sklearn.base import clone
  from sklearn.metrics import r2_score
  from sklearn.metrics import f1_score
  from sklearn.preprocessing import LabelEncoder
  from scipy import stats
  from pandas.api.types import is_numeric_dtype
  from matplotlib.colors import ListedColormap
  from matplotlib.ticker import FormatStrFormatter
  from copy import copy
  import warnings
  import tempfile
  from os import getpid, makedirs
label_desc: Use image node_id 24 for calling a global function with example usage: dectree_max_depth(tree) and returns: walk, max, int