code: def test_UpliftRandomForestClassifier(
      generate_classification_data,
      backend,
      joblib_prefer,
      early_stopping,
  ):
      df, x_names = generate_classification_data()
      df_train, df_test, df_val = None, None, None
  
      if early_stopping == "true":
          df_train, df_test_val = train_test_split(
              df, test_size=0.2, random_state=RANDOM_SEED
          )
          df_test, df_val = train_test_split(
              df_test_val, test_size=0.5, random_state=RANDOM_SEED
          )
      else:
          df_train, df_test = train_test_split(
              df, test_size=0.2, random_state=RANDOM_SEED
          )
  
      with parallel_backend(backend):
          # Train the UpLift Random Forest classifier
          uplift_model = UpliftRandomForestClassifier(
              min_samples_leaf=50,
              control_name=TREATMENT_NAMES[0],
              random_state=RANDOM_SEED,
              joblib_prefer=joblib_prefer,
              early_stopping_eval_diff_scale=1,
          )
          if early_stopping == "true":
              uplift_model.fit(
                  df_train[x_names].values,
                  treatment=df_train["treatment_group_key"].values,
                  y=df_train[CONVERSION].values,
                  X_val=df_val[x_names].values,
                  treatment_val=df_val["treatment_group_key"].values,
                  y_val=df_val[CONVERSION].values,
              )
          else:
              uplift_model.fit(
                  df_train[x_names].values,
                  treatment=df_train["treatment_group_key"].values,
                  y=df_train[CONVERSION].values,
              )
          predictions = {}
          predictions["single"] = uplift_model.predict(
              df_test[x_names].values
          )
          with parallel_backend("loky", n_jobs=2):
              predictions["loky_2"] = uplift_model.predict(
                  df_test[x_names].values
              )
          with parallel_backend("threading", n_jobs=2):
              predictions["threading_2"] = uplift_model.predict(
                  df_test[x_names].values
              )
          with parallel_backend("multiprocessing", n_jobs=2):
              predictions["multiprocessing_2"] = uplift_model.predict(
                  df_test[x_names].values
              )
  
          # assert that the predictions coincide for single and all parallel computations
          iterator = iter(predictions.values())
          first = next(iterator)
          assert all(np.array_equal(first, rest) for rest in iterator)
  
          y_pred = list(predictions.values())[0]
          result = pd.DataFrame(
              y_pred, columns=uplift_model.classes_[1:]
          )
  
          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=list(uplift_model.classes_[1:]))
  
          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
          assert cumgain["uplift_tree"].sum() > cumgain["Random"].sum()
  
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 2 for calling a global function with example usage: test_UpliftRandomForestClassifier(generate_classification_data, backend, joblib_prefer, early_stopping) without return types