code: def ctreeviz_leaf_samples(
      tree_model,
      X_train: (pd.DataFrame, np.ndarray) = None,
      y_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",
      plot_ylim: int = None,
      colors: dict = None,
      fontsize: int = 10,
      fontname: str = "Arial",
      grid: bool = False,
      figsize: tuple = None,
      ax=None,
  ):
      """Visualize the number of data samples by class for each leaf.
  
      It's a good way to see how classes are distributed in leaves. For example, you can observe that in some
      leaves all the samples belong only to one class, or that in other leaves the distribution of classes is almost
      50/50.
      You could get all the samples from these leaves and look over/understand what they have in common. Now, you
      can understand your data in a model driven way.
      Right now it supports only binary classifications decision trees.
  
      We can call this function in two ways :
      1. by using shadow tree
          ex. ctreeviz_leaf_samples(shadow_dtree)
          - we need to initialize shadow_tree before this call
              - ex. shadow_dtree = ShadowSKDTree(tree_model, dataset[features], dataset[target], features, target, [0, 1])
          - the main advantage is that we can use the shadow_tree for other visualisations methods as well
      2. by using sklearn, xgboost tree
          ex. ctreeviz_leaf_samples(tree_classifier, dataset[features], dataset[target], features)
          - maintain backward compatibility
  
      :param tree_model: 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 y_train: pd.Series, np.ndarray
          Target variable
      :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' or 'text'
      :param plot_ylim: int, optional
          The max value for oY. This is useful in case we have few leaves with big sample values which 'shadow'
          the other leaves values.
      :param colors: dict
          The set of colors used for plotting
      :param fontsize: int
          Plot labels fontsize
      :param fontname: str
          Plot labels font name
      :param grid: bool
          True if we want to display the grid lines on the visualization
      :param figsize: optional (width, height) in inches for the entire plot
      :param ax: optional matplotlib "axes" to draw into
      """
      warnings.warn(
          "ctreeviz_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.ctree_leaf_distributions()",
          DeprecationWarning,
          stacklevel=2,
      )
  
      shadow_tree = ShadowDecTree.get_shadow_tree(
          tree_model,
          X_train,
          y_train,
          feature_names,
          None,
          None,
          tree_index,
      )
      model = DTreeVizAPI(shadow_tree)
      model.ctree_leaf_distributions(
          display_type,
          plot_ylim,
          colors,
          fontsize,
          fontname,
          grid,
          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 10 for calling a global function with example usage: ctreeviz_leaf_samples(tree_model, X_train, y_train, feature_names, tree_index, display_type, plot_ylim, colors, fontsize, fontname, grid, figsize, ax) without return types