code: def test_predict(self):
      iterations = 10
      np.random.seed(1)
      test_num_rows = [10, 1000, 5000]
      test_num_cols = [10, 50, 500]
      # This test passes for tree_method=gpu_hist and tree_method=exact. but
      # for `hist` and `approx` the floating point error accumulates faster
      # and fails even tol is set to 1e-4.  For `hist`, the mismatching rate
      # with 5000 rows is 0.04.
      for num_rows in test_num_rows:
          for num_cols in test_num_cols:
              dtrain = xgb.DMatrix(
                  np.random.randn(num_rows, num_cols),
                  label=[0, 1] * int(num_rows / 2),
              )
              dval = xgb.DMatrix(
                  np.random.randn(num_rows, num_cols),
                  label=[0, 1] * int(num_rows / 2),
              )
              dtest = xgb.DMatrix(
                  np.random.randn(num_rows, num_cols),
                  label=[0, 1] * int(num_rows / 2),
              )
              watchlist = [(dtrain, "train"), (dval, "validation")]
              res = {}
              param = {
                  "objective": "binary:logistic",
                  "eval_metric": "logloss",
                  "tree_method": "hist",
                  "device": "gpu:0",
                  "max_depth": 1,
              }
              bst = xgb.train(
                  param,
                  dtrain,
                  iterations,
                  evals=watchlist,
                  evals_result=res,
              )
              assert tm.non_increasing(
                  res["train"]["logloss"], tolerance=0.001
              )
  
              gpu_pred_train = bst.predict(dtrain, output_margin=True)
              gpu_pred_test = bst.predict(dtest, output_margin=True)
              gpu_pred_val = bst.predict(dval, output_margin=True)
  
              bst.set_param({"device": "cpu", "tree_method": "hist"})
              bst_cpu = copy(bst)
              cpu_pred_train = bst_cpu.predict(
                  dtrain, output_margin=True
              )
              cpu_pred_test = bst_cpu.predict(dtest, output_margin=True)
              cpu_pred_val = bst_cpu.predict(dval, output_margin=True)
  
              np.testing.assert_allclose(
                  cpu_pred_train, gpu_pred_train, rtol=1e-6
              )
              np.testing.assert_allclose(
                  cpu_pred_val, gpu_pred_val, rtol=1e-6
              )
              np.testing.assert_allclose(
                  cpu_pred_test, gpu_pred_test, rtol=1e-6
              )
  
imports: import sys
  from copy import copy
  import numpy
  import pytest
  from hypothesis import assume, given, settings, strategies
  import xgboost
  from xgboost import testing
  from xgboost.compat import PANDAS_INSTALLED
  from test_predict import run_predict_leaf
  from test_predict import run_threaded_predict
label_desc: Use image node_id 1 for calling the TestGPUPredict obj's underlying member method code with example usage: obj.test_predict() without return types