code: def test_fil_skl_classification(
      train_device,
      infer_device,
      n_rows,
      n_columns,
      n_estimators,
      max_depth,
      n_classes,
      storage_type,
      precision,
      model_class,
  ):
      with using_device_type(train_device):
          # settings
          classification = (
              True  # change this to false to use regression
          )
          random_state = np.random.RandomState(43210)
  
          X, y = simulate_data(
              n_rows,
              n_columns,
              n_classes,
              random_state=random_state,
              classification=classification,
          )
          # identify shape and indices
          train_size = 0.80
  
          (
              X_train,
              X_validation,
              y_train,
              y_validation,
          ) = train_test_split(
              X, y, train_size=train_size, random_state=0
          )
  
          init_kwargs = {
              "n_estimators": n_estimators,
              "max_depth": max_depth,
          }
          if model_class in [
              RandomForestClassifier,
              ExtraTreesClassifier,
          ]:
              init_kwargs["max_features"] = 0.3
              init_kwargs["n_jobs"] = -1
          else:
              # model_class == GradientBoostingClassifier
              init_kwargs["init"] = "zero"
  
          skl_model = model_class(
              **init_kwargs, random_state=random_state
          )
          skl_model.fit(X_train, y_train)
  
          skl_preds = skl_model.predict(X_validation)
          skl_preds_int = np.around(skl_preds)
          skl_proba = skl_model.predict_proba(X_validation)
  
          skl_acc = accuracy_score(y_validation, skl_preds_int)
  
          fm = ForestInference.load_from_sklearn(
              skl_model, precision=precision, output_class=True
          )
      with using_device_type(infer_device):
          fil_preds = np.asarray(
              fm.predict(X_validation, threshold=0.50)
          )
          fil_preds = np.reshape(fil_preds, np.shape(skl_preds_int))
          fil_acc = accuracy_score(y_validation, fil_preds)
          # fil_acc is within p99 error bars of skl_acc (diff == 0.017 +- 0.012)
          # however, some tests have a delta as big as 0.04.
          # sklearn uses float64 thresholds, while FIL uses float32
          # TODO(levsnv): once FIL supports float64 accuracy, revisit thresholds
          threshold = 1e-5 if n_classes == 2 else 0.1
          assert fil_acc == pytest.approx(skl_acc, abs=threshold)
  
          if n_classes == 2:
              assert array_equal(fil_preds, skl_preds_int)
          fil_proba = np.asarray(fm.predict_proba(X_validation))
          fm.optimize(data=np.expand_dims(X_validation, 0))
          fil_proba_opt = np.asarray(fm.predict_proba(X_validation))
          try:
              fil_proba = np.reshape(fil_proba, np.shape(skl_proba))
              fil_proba_opt = np.reshape(
                  fil_proba_opt, np.shape(skl_proba)
              )
          except ValueError:
              skl_proba = skl_proba[:, 1]
              fil_proba = np.reshape(fil_proba, np.shape(skl_proba))
              fil_proba_opt = np.reshape(
                  fil_proba_opt, np.shape(skl_proba)
              )
          np.testing.assert_allclose(
              fil_proba, skl_proba, atol=proba_atol[n_classes > 2]
          )
          np.testing.assert_allclose(
              fil_proba_opt, fil_proba, atol=proba_atol[n_classes > 2]
          )
  
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 5 for calling a global function with example usage: test_fil_skl_classification(train_device, infer_device, n_rows, n_columns, n_estimators, max_depth, n_classes, storage_type, precision, model_class) without return types