code: def test_predict_per_tree_with_vector_leaf(
      train_device, infer_device, n_classes, tmp_path
  ):
      n_rows = 1000
      n_columns = 30
      n_estimators = 10
  
      with using_device_type(train_device):
          X, y = simulate_data(
              n_rows,
              n_columns,
              n_classes,
              random_state=0,
              classification=True,
          )
  
          skl_model = RandomForestClassifier(
              max_depth=3, random_state=0, n_estimators=n_estimators
          )
          skl_model.fit(X, y)
          tl_model = treelite.sklearn.import_model(skl_model)
          pred_per_tree_tl = treelite.gtil.predict_per_tree(tl_model, X)
          fm = ForestInference.load_from_sklearn(
              skl_model, precision="native", output_class=True
          )
  
      with using_device_type(infer_device):
          pred_per_tree = fm.predict_per_tree(X)
          fm.optimize(
              batch_size=len(X), predict_method="predict_per_tree"
          )
          pred_per_tree_opt = fm.predict_per_tree(X)
          margin_pred = skl_model.predict_proba(X)
          assert pred_per_tree.shape == (
              n_rows,
              n_estimators,
              n_classes,
          )
          avg_by_class = np.sum(pred_per_tree, axis=1) / n_estimators
          np.testing.assert_almost_equal(
              avg_by_class, margin_pred, decimal=3
          )
          np.testing.assert_almost_equal(
              pred_per_tree, pred_per_tree_tl, decimal=3
          )
          np.testing.assert_almost_equal(
              pred_per_tree_opt, pred_per_tree, decimal=3
          )
  
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 14 for calling a global function with example usage: test_predict_per_tree_with_vector_leaf(train_device, infer_device, n_classes, tmp_path) without return types