code: def get_xgboost_node_dict(xgboost_treedump):
      """Turns the output of a xgboostmodel.get_dump() into a dictionary
      of nodes for easy parsing a prediction path through individual trees
      in the model.
  
      Args:
          xgboost_treedump (str): a single element of the list output from
              xgboost model.get_dump() that represents a single tree in the
              ensemble.
      Returns:
          dict
      """
      node_dict = {}
      for row in xgboost_treedump.splitlines():
          s = row.strip()
          node = int(re.search(r"^(.*)\:", s).group(1))
          is_leaf = re.search(r":(.*)\=", s).group(1) == "leaf"
  
          leaf_value = (
              re.search(r"leaf=(.*)$", s).group(1) if is_leaf else None
          )
          feature = (
              re.search(r"\[(.*)\<", s).group(1)
              if not is_leaf
              else None
          )
          cutoff = (
              float(re.search(r"\<(.*)\]", s).group(1))
              if not is_leaf
              else None
          )
          left_node = (
              int(re.search(r"yes=(.*)\,no", s).group(1))
              if not is_leaf
              else None
          )
          right_node = (
              int(re.search(r"no=(.*)\,", s).group(1))
              if not is_leaf
              else None
          )
          node_dict[node] = dict(
              node=node,
              is_leaf=is_leaf,
              leaf_value=leaf_value,
              feature=feature,
              cutoff=cutoff,
              left_node=left_node,
              right_node=right_node,
          )
      return node_dict
  
imports: from functools import partial
  import re
  from collections import Counter
  from typing import List, Union
  import warnings
  import numpy
  import pandas
  from pandas.api.types import is_numeric_dtype, is_categorical_dtype
  from dtreeviz.trees import ShadowDecTree
  from sklearn.metrics import make_scorer
  from sklearn.base import clone
  from sklearn.pipeline import Pipeline
  from sklearn.model_selection import KFold, StratifiedKFold
  from joblib import Parallel, delayed
label_desc: Use image node_id 29 for calling a global function with example usage: get_xgboost_node_dict(xgboost_treedump) and returns: node_dict