code: def test_sparse_dmatrix_csr(self):
      nrow = 100
      ncol = 1000
      x = rand(
          nrow, ncol, density=0.0005, format="csr", random_state=rng
      )
      assert x.indices.max() < ncol
      x.data[:] = 1
      dtrain = xgb.DMatrix(x, label=rng.binomial(1, 0.3, nrow))
      assert (dtrain.num_row(), dtrain.num_col()) == (nrow, ncol)
      watchlist = [(dtrain, "train")]
      param = {"max_depth": 3, "objective": "binary:logistic"}
      bst = xgb.train(param, dtrain, 5, watchlist)
      bst.predict(dtrain)
  
      i32 = csr_matrix(
          (x.data.astype(np.int32), x.indices, x.indptr), shape=x.shape
      )
      f32 = csr_matrix(
          (i32.data.astype(np.float32), x.indices, x.indptr),
          shape=x.shape,
      )
      di32 = xgb.DMatrix(i32)
      df32 = xgb.DMatrix(f32)
      dense = xgb.DMatrix(f32.toarray(), missing=0)
      with tempfile.TemporaryDirectory() as tmpdir:
          path = os.path.join(tmpdir, "f32.dmatrix")
          df32.save_binary(path)
          with open(path, "rb") as fd:
              df32_buffer = np.array(fd.read())
          path = os.path.join(tmpdir, "f32.dmatrix")
          di32.save_binary(path)
          with open(path, "rb") as fd:
              di32_buffer = np.array(fd.read())
  
          path = os.path.join(tmpdir, "dense.dmatrix")
          dense.save_binary(path)
          with open(path, "rb") as fd:
              dense_buffer = np.array(fd.read())
  
          np.testing.assert_equal(df32_buffer, di32_buffer)
          np.testing.assert_equal(df32_buffer, dense_buffer)
  
imports: import csv
  import os
  import tempfile
  import warnings
  import numpy
  import pytest
  import scipy.sparse
  from hypothesis import given, settings, strategies
  from scipy.sparse import csr_matrix, rand
  import xgboost
  from xgboost import testing
  from xgboost.core import DataSplitMode
  from xgboost.testing.data import np_dtypes, run_base_margin_info
label_desc: Use image node_id 11 for calling the TestDMatrix obj's underlying member method code with example usage: obj.test_sparse_dmatrix_csr() without return types