code: def test_apply(train_device, infer_device, n_classes, tmp_path):
      n_rows = 1000
      n_columns = 30
      num_boost_round = 10
  
      with using_device_type(train_device):
          X, y = simulate_data(
              n_rows,
              n_columns,
              n_classes,
              random_state=0,
              classification=True,
          )
  
          model_path = os.path.join(tmp_path, "xgb_class.model")
  
          xgboost_params = {
              "base_score": (0.5 if n_classes == 2 else 0.0)
          }
          bst = _build_and_save_xgboost(
              model_path,
              X,
              y,
              num_rounds=num_boost_round,
              classification=True,
              n_classes=n_classes,
              xgboost_params=xgboost_params,
          )
  
          fm = ForestInference.load(
              model_path, output_class=True, model_type="xgboost"
          )
  
      with using_device_type(infer_device):
          pred_leaf = fm.apply(X).astype(np.int32)
          expected_pred_leaf = bst.predict(
              xgb.DMatrix(X), pred_leaf=True
          )
          if n_classes == 2:
              expected_shape = (n_rows, num_boost_round)
          else:
              expected_shape = (n_rows, num_boost_round * n_classes)
          assert pred_leaf.shape == expected_shape
          np.testing.assert_equal(pred_leaf, expected_pred_leaf)
  
imports: import numpy
  import pytest
  import os
  import pandas
  from math import ceil
  from cuml.experimental import ForestInference
  from cuml.testing.utils import array_equal, unit_param, quality_param, stress_param
  from cuml.internals.import_utils import has_lightgbm, has_xgboost
  from cuml.common.device_selection import using_device_type
  from sklearn.datasets import make_classification, make_regression
  from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor, RandomForestClassifier, RandomForestRegressor, ExtraTreesClassifier, ExtraTreesRegressor
  from sklearn.metrics import accuracy_score, mean_squared_error
  from sklearn.model_selection import train_test_split
  import treelite
label_desc: Use image node_id 15 for calling a global function with example usage: test_apply(train_device, infer_device, n_classes, tmp_path) without return types