code: def viz_leaf_samples(
      tree_model,
      X_train: (pd.DataFrame, np.ndarray) = None,
      feature_names: List[str] = None,
      tree_index: int = None,  # required in case of tree ensemble
      display_type: str = "plot",
      colors: dict = None,
      fontsize: int = 10,
      fontname: str = "Arial",
      grid: bool = False,
      bins: int = 10,
      min_samples: int = 0,
      max_samples: int = None,
      figsize: tuple = None,
      ax=None,
  ):
      """Visualize the number of data samples from each leaf.
  
      Interpreting leaf samples can help us to see how the data is spread over the tree:
      - if we have a leaf with many samples and a good impurity, it means that we can be pretty confident
      on its prediction.
      - if we have a leaf with few samples and a good impurity, we cannot be very confident on its predicion and
      it could be a sign of overfitting.
      - by visualizing leaf samples, we can easily discover important leaves . Using describe_node_sample() function we
      can take all its samples and discover common patterns between leaf samples.
      - if the tree contains a lot of leaves and we want a general overview about leaves samples, we can use the
      parameter display_type='hist' to display the histogram of leaf samples.
  
      There is the option to filter the leaves with samples between 'min_samples' and 'max_samples'. This is helpful
      especially when you want to investigate leaves with number of samples from a specific range.
  
  
      We can call this function in two ways :
      1. by using shadow tree
          ex. viz_leaf_samples(shadow_dtree)
          - we need to initialize shadow_tree before this call
              - ex. shadow_dtree = ShadowSKDTree(tree_model, dataset[features], features)
          - the main advantage is that we can use the shadow_tree for other visualisations methods as well
      2. by using sklearn, xgboost tree
          ex. viz_leaf_samples(tree_model, dataset[features], dataset[target], features, target)
          - maintain backward compatibility
  
      TODO : put a link with notebook examples (at each function docs)
  
      This method contains three types of visualizations:
      - If display_type = 'plot' it will show leaf samples using a plot.
      - If display_type = 'text' it will show leaf samples as plain text. This method is preferred if number
      of leaves is very large and the plot become very big and hard to interpret.
      - If display_type = 'hist' it will show leaf sample histogram. Useful when you want to easily see the general
      distribution of leaf samples.
  
      Note : If the X_train and y_train are the datasets used to trained the model, then we will investigate the tree model
      as it was trained. We can give other X_train and y_train datasets, ex. validation dataset, to see how the new data is
      spread over the tree.
  
      :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 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.
      :param display_type: str, optional
         'plot', 'text'. 'hist'
      :param colors: dict
          The set of colors used for plotting
      :param fontsize: int
          Plot labels font size
      :param fontname: str
          Plot labels font name
      :param grid: bool
          True if we want to display the grid lines on the visualization
      :param bins: int
          Number of histogram bins
      :param min_samples: int
          Min number of samples for a leaf
      :param max_samples: int
          Max number of samples for a leaf
      :param figsize: optional (width, height) in inches for the entire plot
      :param ax: optional matplotlib "axes" to draw into
      """
      warnings.warn(
          "viz_leaf_samples() function is deprecated starting from version 2.0. \n "
          "For the same functionality, please use this code instead: \n m = dtreeviz.model(...) \n m.leaf_sizes()",
          DeprecationWarning,
          stacklevel=2,
      )
  
      shadow_tree = ShadowDecTree.get_shadow_tree(
          tree_model,
          X_train,
          None,
          feature_names,
          None,
          None,
          tree_index,
      )
      model = DTreeVizAPI(shadow_tree)
      model.leaf_sizes(
          display_type,
          colors,
          fontsize,
          fontname,
          grid,
          bins,
          min_samples,
          max_samples,
          figsize,
          ax,
      )
  
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 8 for calling a global function with example usage: viz_leaf_samples(tree_model, X_train, feature_names, tree_index, display_type, colors, fontsize, fontname, grid, bins, min_samples, max_samples, figsize, ax) without return types