code: def test_fil_classification(
      train_device,
      infer_device,
      n_rows,
      n_columns,
      num_rounds,
      n_classes,
      tmp_path,
  ):
      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
          n_rows, n_columns = X.shape
  
          (
              X_train,
              X_validation,
              y_train,
              y_validation,
          ) = train_test_split(X, y, train_size=0.8, random_state=0)
  
          model_path = os.path.join(tmp_path, "xgb_class.model")
  
          bst = _build_and_save_xgboost(
              model_path,
              X_train,
              y_train,
              num_rounds=num_rounds,
              classification=classification,
              n_classes=n_classes,
          )
  
          dvalidation = xgb.DMatrix(X_validation, label=y_validation)
  
          if n_classes == 2:
              xgb_preds = bst.predict(dvalidation)
              xgb_preds_int = np.around(xgb_preds)
          else:
              xgb_preds = bst.predict(dvalidation)
              xgb_preds_int = xgb_preds.argmax(axis=1)
          xgb_acc = accuracy_score(y_validation, xgb_preds_int)
  
          fm = ForestInference.load(model_path, output_class=True)
      with using_device_type(infer_device):
          fil_preds = np.reshape(
              np.asarray(fm.predict(X_validation, threshold=0.50)),
              xgb_preds_int.shape,
          )
          fil_proba = np.reshape(
              np.asarray(fm.predict_proba(X_validation)),
              xgb_preds.shape,
          )
          fm.optimize(batch_size=len(X_validation))
          fil_preds_opt = np.reshape(
              np.asarray(fm.predict(X_validation, threshold=0.50)),
              xgb_preds_int.shape,
          )
          fil_proba_opt = np.reshape(
              np.asarray(fm.predict_proba(X_validation)),
              xgb_preds.shape,
          )
          fil_acc = accuracy_score(y_validation, fil_preds)
  
          assert fil_acc == pytest.approx(xgb_acc, abs=0.01)
          assert array_equal(fil_preds, xgb_preds_int)
          assert array_equal(fil_preds_opt, fil_preds)
          np.testing.assert_allclose(
              fil_proba, xgb_preds, 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 3 for calling a global function with example usage: test_fil_classification(train_device, infer_device, n_rows, n_columns, num_rounds, n_classes, tmp_path) without return types