code: def compute_error_tree_on_dataset(
      analyzer,
      features,
      dataset,
      max_depth=DEFAULT_MAX_DEPTH,
      num_leaves=DEFAULT_NUM_LEAVES,
      min_child_samples=DEFAULT_MIN_CHILD_SAMPLES,
  ):
      """Computes the error tree for the given dataset.
  
      :param analyzer: The error analyzer containing the categorical
          features and categories for the full dataset.
      :type analyzer: BaseAnalyzer
      :param features: The features to train the surrogate model on.
      :type features: numpy.ndarray or pandas.DataFrame
      :param dataset: The dataset on which matrix view needs to be computed.
          The dataset should have the feature columns and the columns
          'true_y' and 'index'. The 'true_y' column should have the true
          target values corresponding to the test data. The 'index'
          column should have the indices. If the analyzer is of type
          PredictionsAnalyzer, then the dataset should include the column
          'pred_y' which will hold the predictions.
      :type dataset: pd.DataFrame
      :param max_depth: The maximum depth of the surrogate tree trained
          on errors.
      :type max_depth: int
      :param num_leaves: The number of leaves of the surrogate tree
          trained on errors.
      :type num_leaves: int
      :param min_child_samples: The minimal number of data required to
          create one leaf.
      :return: The tree representation as a list of nodes.
      :rtype: list[dict[str, str]]
      """
      if max_depth is None:
          max_depth = DEFAULT_MAX_DEPTH
      if num_leaves is None:
          num_leaves = DEFAULT_NUM_LEAVES
      if min_child_samples is None:
          min_child_samples = DEFAULT_MIN_CHILD_SAMPLES
  
      if dataset.shape[0] == 0:
          return create_empty_node(analyzer.metric)
      is_model_analyzer = hasattr(analyzer, MODEL)
      indexes = []
      for feature in features:
          if feature not in analyzer.feature_names:
              msg = "Feature {} not found in dataset. Existing features: {}"
              raise UserConfigValidationException(
                  msg.format(feature, analyzer.feature_names)
              )
          indexes.append(analyzer.feature_names.index(feature))
      dataset_sub_names = np.array(analyzer.feature_names)[
          np.array(indexes)
      ]
      dataset_sub_names = list(dataset_sub_names)
      if not is_spark(dataset):
          (
              booster,
              dataset_indexed_df,
              cat_info,
          ) = get_surrogate_booster_local(
              dataset,
              analyzer,
              is_model_analyzer,
              indexes,
              dataset_sub_names,
              max_depth,
              num_leaves,
              min_child_samples,
          )
          cat_ind_reindexed, categories_reindexed = cat_info
      else:
          booster, dataset_indexed_df = get_surrogate_booster_pyspark(
              dataset,
              analyzer,
              max_depth,
              num_leaves,
              min_child_samples,
          )
          cat_ind_reindexed = []
          categories_reindexed = []
      dumped_model = booster.dump_model()
      tree_structure = dumped_model["tree_info"][0]["tree_structure"]
      max_split_index = get_max_split_index(tree_structure) + 1
      cache_subtree_features(tree_structure, dataset_sub_names)
      tree = traverse(
          dataset_indexed_df,
          tree_structure,
          max_split_index,
          (categories_reindexed, cat_ind_reindexed),
          [],
          dataset_sub_names,
          metric=analyzer.metric,
          classes=analyzer.classes,
      )
      return tree
  
imports: import logging
  import numbers
  from enum import Enum
  import numpy
  import pandas
  from lightgbm import Booster, LGBMClassifier, LGBMRegressor
  from sklearn.metrics import mean_absolute_error, mean_squared_error, median_absolute_error, r2_score
  from erroranalysis._internal.cohort_filter import filter_from_cohort
  from erroranalysis._internal.constants import DIFF, LEAF_INDEX, METHOD, PRED_Y, ROW_INDEX, SPLIT_FEATURE, SPLIT_INDEX, TRUE_Y, CohortFilterMethods, Metrics, ModelTask, TreeNode, error_metrics, f1_metrics, metric_to_display_name, precision_metrics, recall_metrics, regression_metrics
  from erroranalysis._internal.metrics import get_ordered_classes, metric_to_func
  from erroranalysis._internal.process_categoricals import process_categoricals
  from erroranalysis._internal.utils import is_spark
  from raiutils.exceptions import UserConfigValidationException
label_desc: Use image node_id 2 for calling a global function with example usage: compute_error_tree_on_dataset(analyzer, features, dataset, max_depth, num_leaves, min_child_samples) and returns: tree, create_empty_node