code: def UpliftTreeClassifierTesting(df, x_names, evaluation_function):
      df_train, df_test = train_test_split(
          df, test_size=0.2, random_state=RANDOM_SEED
      )
  
      # Train the UpLift Random Forest classifier
      uplift_model = UpliftTreeClassifier(
          control_name=TREATMENT_NAMES[0],
          random_state=RANDOM_SEED,
          evaluationFunction=evaluation_function,
      )
  
      if evaluation_function == "IDDP":
          assert uplift_model.honesty is True
  
      pr = cProfile.Profile(
          subcalls=True, builtins=True, timeunit=0.001
      )
      pr.enable()
      uplift_model.fit(
          df_train[x_names].values,
          treatment=df_train["treatment_group_key"].values,
          y=df_train[CONVERSION].values,
      )
  
      y_pred = uplift_model.predict(df_test[x_names].values)
      pr.disable()
      with open("UpliftTreeClassifier.prof", "w") as f:
          ps = pstats.Stats(pr, stream=f).sort_stats("cumulative")
          ps.print_stats()
  
      result = pd.DataFrame(y_pred, columns=uplift_model.classes_)
      result.drop(CONTROL_NAME, axis=1, inplace=True)
  
      best_treatment = np.where(
          (result < 0).all(axis=1), CONTROL_NAME, result.idxmax(axis=1)
      )
  
      # Create a synthetic population:
  
      # Create indicator variables for whether a unit happened to have the
      # recommended treatment or was in the control group
      actual_is_best = np.where(
          df_test["treatment_group_key"] == best_treatment, 1, 0
      )
      actual_is_control = np.where(
          df_test["treatment_group_key"] == CONTROL_NAME, 1, 0
      )
  
      synthetic = (actual_is_best == 1) | (actual_is_control == 1)
      synth = result[synthetic]
  
      auuc_metrics = synth.assign(
          is_treated=1 - actual_is_control[synthetic],
          conversion=df_test.loc[synthetic, CONVERSION].values,
          uplift_tree=synth.max(axis=1),
      ).drop(columns=result.columns)
  
      cumgain = get_cumgain(
          auuc_metrics,
          outcome_col=CONVERSION,
          treatment_col="is_treated",
      )
  
      # Check if the cumulative gain of UpLift Random Forest is higher than
      # random (sometimes IT and IDDP are not better than random)
      assert cumgain["uplift_tree"].sum() > cumgain["Random"].sum()
  
      # Check if the total count is split correctly, at least for control group in the first level
      def validate_cnt(cur_tree):
          parent_control_cnt = cur_tree.nodeSummary[0][1]
          next_level_control_cnt = 0
          # assume the depth is at least 2
          assert cur_tree.trueBranch or cur_tree.falseBranch
          if cur_tree.trueBranch:
              next_level_control_cnt += cur_tree.trueBranch.nodeSummary[
                  0
              ][1]
          if cur_tree.falseBranch:
              next_level_control_cnt += (
                  cur_tree.falseBranch.nodeSummary[0][1]
              )
          return [parent_control_cnt, next_level_control_cnt]
  
      counts = validate_cnt(uplift_model.fitted_uplift_tree)
      assert counts[0] > 0 and counts[0] == counts[1]
  
      # Check if it works as expected after filling with validation data
      uplift_model.fill(
          df_test[x_names].values,
          treatment=df_test["treatment_group_key"].values,
          y=df_test[CONVERSION].values,
      )
      counts = validate_cnt(uplift_model.fitted_uplift_tree)
      assert counts[0] > 0 and counts[0] == counts[1]
  
file_path: causalml/tests/test_uplift_trees.py
imports: import cProfile
  import numpy
  import pandas
  import pytest
  import pstats
  from joblib import parallel_backend
  from sklearn.model_selection import train_test_split
  from causalml.inference.tree import UpliftTreeClassifier, UpliftRandomForestClassifier
  from causalml.metrics import get_cumgain
  from causalml.dataset import make_uplift_classification
  from causalml.inference.tree import uplift_tree_string, uplift_tree_plot
  from .const import RANDOM_SEED, N_SAMPLE, CONTROL_NAME, TREATMENT_NAMES, CONVERSION
label_desc: Use image node_id 5 for calling a global function with example usage: UpliftTreeClassifierTesting(df, x_names, evaluation_function) and returns: list