code: def test_to_csr(self, n_samples, n_features, sparsity) -> None:
      import cupy as cp
  
      X, y = tm.make_sparse_regression(
          n_samples, n_features, sparsity, False
      )
      h_X = X.astype(np.float32)
  
      csr = h_X
      h_X = X.toarray()
      h_X[h_X == 0] = np.nan
  
      h_m = xgb.QuantileDMatrix(data=h_X)
      h_ret = h_m.get_data()
  
      d_X = cp.array(h_X)
  
      d_m = xgb.QuantileDMatrix(data=d_X, label=y)
      d_ret = d_m.get_data()
  
      np.testing.assert_equal(csr.indptr, d_ret.indptr)
      np.testing.assert_equal(csr.indices, d_ret.indices)
  
      np.testing.assert_equal(h_ret.indptr, d_ret.indptr)
      np.testing.assert_equal(h_ret.indices, d_ret.indices)
  
      booster = xgb.train(
          {"tree_method": "hist", "device": "cuda:0"}, dtrain=d_m
      )
  
      np.testing.assert_allclose(
          booster.predict(d_m),
          booster.predict(xgb.DMatrix(d_m.get_data())),
          atol=1e-6,
      )
  
file_path: xgboost/tests/python-gpu/test_device_quantile_dmatrix.py
imports: import sys
  import numpy
  import pytest
  from hypothesis import given, settings, strategies
  import xgboost
  from xgboost import testing
  from xgboost.testing.data import check_inf
  from xgboost.testing.data_iter import run_mixed_sparsity
  import test_quantile_dmatrix
label_desc: Use image node_id 7 for calling the TestQuantileDMatrix obj's underlying member method code with example usage: obj.test_to_csr(n_samples, n_features, sparsity) without return types