code: def get_surrogate_booster_local(
      filtered_df,
      analyzer,
      is_model_analyzer,
      indexes,
      dataset_sub_names,
      max_depth,
      num_leaves,
      min_child_samples,
  ):
      """Get surrogate booster for local pandas DataFrame.
  
      Creates the surrogate model trained on errors and returns the booster.
  
      :param filtered_df: The filtered DataFrame.
      :type filtered_df: pandas.DataFrame
      :param analyzer: The error analyzer containing the categorical
          features and categories for the full dataset.
      :type analyzer: BaseAnalyzer
      :param is_model_analyzer: Whether the analyzer is a model analyzer.
      :type is_model_analyzer: bool
      :param indexes: The indexes of the features to train the surrogate model
          on.
      :type indexes: list[int]
      :param dataset_sub_names: The names of the features to train the
          surrogate model on.
      :type dataset_sub_names: list[str]
      :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.
      :type min_child_samples: int
      :return: The extracted booster from the surrogate model and the
          scored dataset.
      :rtype: (Booster, pandas.DataFrame, (list[str], list[int]))
      """
      true_y = filtered_df[TRUE_Y]
      dropped_cols = [TRUE_Y, ROW_INDEX]
      if not is_model_analyzer:
          pred_y = filtered_df[PRED_Y]
          dropped_cols.append(PRED_Y)
      input_data = filtered_df.drop(columns=dropped_cols)
      is_pandas = isinstance(analyzer.dataset, pd.DataFrame)
      if is_pandas:
          true_y = true_y.to_numpy()
      else:
          input_data = input_data.to_numpy(copy=True)
      if is_model_analyzer:
          pred_y = analyzer.model.predict(input_data)
      if analyzer.model_task == ModelTask.CLASSIFICATION:
          diff = pred_y != true_y
      elif analyzer.model_task == ModelTask.OBJECT_DETECTION:
          if not pytorch_installed:
              raise ModuleNotFoundError(
                  "User Error: torch & torchvision are not installed "
                  "and are needed for the Object Detection scenario."
              )
          diff = [
              len(
                  ErrorLabeling(
                      ModelTask.OBJECT_DETECTION,
                      pred_y[image_idx],
                      true_y[image_idx],
                  ).compute_error_list()
              )
              > 0
              for image_idx in range(len(true_y))
          ]
      else:
          diff = pred_y - true_y
      if not isinstance(diff, np.ndarray):
          diff = np.array(diff)
      if not isinstance(pred_y, np.ndarray):
          pred_y = np.array(pred_y)
      if not isinstance(true_y, np.ndarray):
          true_y = np.array(true_y)
      if is_pandas:
          input_data = input_data.to_numpy(copy=True)
  
      if analyzer.categorical_features:
          # Inplace replacement of columns
          if len(input_data) != len(analyzer.string_indexed_data):
              _, _, _, string_indexed_data = process_categoricals(
                  all_feature_names=analyzer._feature_names,
                  categorical_features=analyzer._categorical_features,
                  dataset=input_data,
              )
          else:
              string_indexed_data = analyzer.string_indexed_data
          for idx, c_i in enumerate(analyzer.categorical_indexes):
              input_data[:, c_i] = string_indexed_data[:, idx]
      dataset_sub_features = input_data[:, indexes]
  
      categorical_info = get_categorical_info(
          analyzer, dataset_sub_names
      )
      cat_ind_reindexed, categories_reindexed = categorical_info
  
      surrogate = create_surrogate_model(
          analyzer,
          dataset_sub_features,
          diff,
          max_depth,
          num_leaves,
          min_child_samples,
          cat_ind_reindexed,
      )
  
      filtered_indexed_df = pd.DataFrame(
          dataset_sub_features, columns=dataset_sub_names
      )
      filtered_indexed_df[DIFF] = diff
      filtered_indexed_df[TRUE_Y] = true_y
      filtered_indexed_df[PRED_Y] = pred_y
      return surrogate._Booster, filtered_indexed_df, categorical_info
  
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 4 for calling a global function with example usage: get_surrogate_booster_local(filtered_df, analyzer, is_model_analyzer, indexes, dataset_sub_names, max_depth, num_leaves, min_child_samples) and returns: surrogate,  filtered_indexed_df,  categorical_info