code: def describe_node_sample(
      tree_model,
      node_id: int,
      X_train: (pd.DataFrame, np.ndarray) = None,
      feature_names: List[str] = None,
      tree_index: int = None,  # required in case of tree ensemble
  ):
      """Generate stats (count, mean, std, etc) based on data samples from a specified node.
  
      This method is especially useful to investigate leaf samples from a decision tree. This is a way to discover data
      patterns, to better understand our tree model and to get new ideas for feature generation.
  
      We can call this function in two ways :
      1. by using shadow tree
          ex. describe_node_sample(shadow_dtree, node_id=10)
          - we need to initialize shadow_tree before this call
              - ex. shadow_dtree = ShadowSKDTree(tree_model, dataset[features], dataset[target], features, target)
          - the main advantage is that we can use the shadow_tree for other visualisations methods as well
      2. by using sklearn, xgboost tree
          ex. describe_node_sample(tree_classifier, node_id=1, X_train=dataset[features], feature_names=features)
          - maintain backward compatibility
  
      :param tree_model: tree.DecisionTreeRegressor, tree.DecisionTreeClassifier, xgboost.core.Booster,
                  dtreeviz.models.sklearn_decision_trees.ShadowSKDTree,
                  dtreeviz.models.xgb_decision_trees.ShadowXGBDTree
          The tree model or dtreeviz shadow tree model to interpret
      :param node_id: int
          Node id to interpret
      :param X_train: pd.DataFrame, np.ndarray
          The dataset based on which we want to make this visualisation.
      :param feature_names: List[str], optional
          The list of feature variable's name
      :param tree_index: int, optional
          Required in case of tree ensemble. Specify the tree index to interpret.
      :return: pd.DataFrame
          Node training samples' stats
      """
      warnings.warn(
          "describe_node_sample() function is deprecated starting from version 2.0. \n "
          "For the same functionality, please use this code instead: \n m = dtreeviz.model(...) \n m.node_stats()",
          DeprecationWarning,
          stacklevel=2,
      )
  
      shadow_tree = ShadowDecTree.get_shadow_tree(
          tree_model,
          X_train,
          None,
          feature_names,
          None,
          None,
          tree_index,
      )
      model = DTreeVizAPI(shadow_tree)
      return model.node_stats(node_id)
  
imports: import warnings
  from numbers import Number
  from typing import Mapping, List
  import numpy
  import pandas
  from sklearn import tree
  from dtreeviz.models.shadow_decision_tree import ShadowDecTree
  from dtreeviz.utils import myround, DTreeVizRender
  from dtreeviz.trees import DTreeVizAPI
label_desc: Use image node_id 12 for calling a global function with example usage: describe_node_sample(tree_model, node_id, X_train, feature_names, tree_index) and returns: model