code: def dtreeviz(
      tree_model,
      X_train: (pd.DataFrame, np.ndarray) = None,
      y_train: (pd.DataFrame, np.ndarray) = None,
      feature_names: List[str] = None,
      target_name: str = None,
      class_names: (
          Mapping[Number, str],
          List[str],
      ) = None,  # required if classifier,
      tree_index: int = None,  # required in case of tree ensemble,
      precision: int = 2,
      orientation: ("TD", "LR") = "TD",
      instance_orientation: ("TD", "LR") = "LR",
      show_root_edge_labels: bool = True,
      show_node_labels: bool = False,
      show_just_path: bool = False,
      fancy: bool = True,
      histtype: ("bar", "barstacked", "strip") = "barstacked",
      highlight_path: List[int] = [],
      X: np.ndarray = None,
      max_X_features_LR: int = 10,
      max_X_features_TD: int = 20,
      depth_range_to_display: tuple = None,
      label_fontsize: int = 12,
      ticks_fontsize: int = 8,
      fontname: str = "Arial",
      title: str = None,
      title_fontsize: int = 10,
      colors: dict = None,
      scale=1.0,
  ) -> DTreeVizRender:
      """
      Given a decision tree regressor or classifier, create and return a tree visualization
      using the graphviz (DOT) language.
  
      We can call this function in two ways :
      1. by using shadow tree
          ex. dtreeviz(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. dtreeviz(tree_model, dataset[features], dataset[target], features, target, class_names=[0, 1])
          - maintain backward compatibility
  
      :param tree_model: A DecisionTreeRegressor or DecisionTreeClassifier that has been
                         fit to X_train, y_train.
      :param X_train: A data frame or 2-D matrix of feature vectors used to train the model.
      :param y_train: A pandas Series or 1-D vector with target or classes values. These values should be numeric types.
      :param feature_names: A list of the feature names.
      :param target_name: The name of the target variable.
      :param class_names: [For classifiers] A dictionary or list of strings mapping class
                          value to class name.
      :param precision: When displaying floating-point numbers, how many digits to display
                        after the decimal point. Default is 2.
      :param orientation:  Is the tree top down, "TD", or left to right, "LR"?
      :param instance_orientation: table orientation (TD, LR) for showing feature prediction's values.
      :param show_root_edge_labels: Include < and >= on the edges emanating from the root?
      :param show_node_labels: Add "Node id" to top of each node in graph for educational purposes
      :param show_just_path: If True, it shows only the sample(X) prediction path
      :param fancy:
      :param histtype: [For classifiers] Either 'bar' or 'barstacked' to indicate
                       histogram type. We find that 'barstacked' looks great up to about.
                       four classes.
      :param highlight_path: A list of node IDs to highlight, default is [].
                             Useful for emphasizing node(s) in tree for discussion.
                             If X argument given then this is ignored.
      :type highlight_path: List[int]
      :param X: Instance to run down the tree; derived path to highlight from this vector.
                Show feature vector with labels underneath leaf reached. highlight_path
                is ignored if X is not None.
      :type X: np.ndarray
      :param label_fontsize: Size of the label font
      :param ticks_fontsize: Size of the tick font
      :param fontname: Font which is used for labels and text
      :param max_X_features_LR: If len(X) exceeds this limit for LR layout,
                              display only those features
                             used to guide X vector down tree. Helps when len(X) is large.
                             Default is 10.
      :param max_X_features_TD: If len(X) exceeds this limit for TD layout,
                              display only those features
                             used to guide X vector down tree. Helps when len(X) is large.
                             Default is 25.
      :param depth_range_to_display: range of depth levels to be displayed. The range values are inclusive
      :param title: An optional title placed at the top of the tree.
      :param title_fontsize: Size of the text for the title.
      :param scale: Default is 1.0. Scale the width, height of the overall SVG preserving aspect ratio
      :return: A string in graphviz DOT language that describes the decision tree.
      """
      warnings.warn(
          "dtreeviz() function is deprecated starting from version 2.0. \n "
          "For the same functionality, please use this code instead: \n m = dtreeviz.model(...) \n m.view()",
          DeprecationWarning,
          stacklevel=2,
      )
  
      shadow_tree = ShadowDecTree.get_shadow_tree(
          tree_model,
          X_train,
          y_train,
          feature_names,
          target_name,
          class_names,
          tree_index,
      )
      model = DTreeVizAPI(shadow_tree)
      return model.view(
          precision,
          orientation,
          instance_orientation,
          show_root_edge_labels,
          show_node_labels,
          show_just_path,
          fancy,
          histtype,
          highlight_path,
          X,
          max_X_features_LR,
          max_X_features_TD,
          depth_range_to_display,
          label_fontsize,
          ticks_fontsize,
          fontname,
          title,
          title_fontsize,
          colors=colors,
          scale=scale,
      )
  
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 7 for calling a global function with example usage: dtreeviz(tree_model, X_train, y_train, feature_names, target_name, class_names, tree_index, precision, orientation, instance_orientation, show_root_edge_labels, show_node_labels, show_just_path, fancy, histtype, highlight_path, X, max_X_features_LR, max_X_features_TD, depth_range_to_display, label_fontsize, ticks_fontsize, fontname, title, title_fontsize, colors, scale) and returns: model