code: def test_fil_regression(
      train_device,
      infer_device,
      n_rows,
      n_columns,
      num_rounds,
      tmp_path,
      max_depth,
  ):
      with using_device_type(train_device):
          # settings
          classification = (
              False  # change this to false to use regression
          )
          random_state = np.random.RandomState(43210)
  
          X, y = simulate_data(
              n_rows,
              n_columns,
              random_state=random_state,
              classification=classification,
              bias=10.0,
          )
          # identify shape and indices
          n_rows, n_columns = X.shape
          train_size = 0.80
  
          (
              X_train,
              X_validation,
              y_train,
              y_validation,
          ) = train_test_split(
              X, y, train_size=train_size, random_state=0
          )
  
          model_path = os.path.join(tmp_path, "xgb_reg.model")
          bst = _build_and_save_xgboost(
              model_path,
              X_train,
              y_train,
              classification=classification,
              num_rounds=num_rounds,
              xgboost_params={"max_depth": max_depth},
          )
  
          dvalidation = xgb.DMatrix(X_validation, label=y_validation)
          xgb_preds = bst.predict(dvalidation)
  
          xgb_mse = mean_squared_error(y_validation, xgb_preds)
          fm = ForestInference.load(model_path, output_class=False)
      with using_device_type(infer_device):
          fil_preds = np.asarray(fm.predict(X_validation))
          fil_preds = np.reshape(fil_preds, np.shape(xgb_preds))
          fil_mse = mean_squared_error(y_validation, fil_preds)
          fm.optimize(data=X_validation)
          fil_preds_opt = np.asarray(fm.predict(X_validation))
          fil_preds_opt = np.reshape(fil_preds_opt, np.shape(xgb_preds))
  
          assert fil_mse == pytest.approx(xgb_mse, abs=0.01)
          assert np.allclose(fil_preds, xgb_preds, 1e-3)
          assert np.allclose(fil_preds_opt, fil_preds, 1e-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 4 for calling a global function with example usage: test_fil_regression(train_device, infer_device, n_rows, n_columns, num_rounds, tmp_path, max_depth) without return types