code: def main():
      rounds = 100
      it = IterForDMatrixDemo()
  
      # Use iterator, must be `QuantileDMatrix`.
  
      # In this demo, the input batches are created using cupy, and the data processing
      # (quantile sketching) will be performed on GPU. If data is loaded with CPU based
      # data structures like numpy or pandas, then the processing step will be performed
      # on CPU instead.
      m_with_it = xgboost.QuantileDMatrix(it)
  
      # Use regular DMatrix.
      m = xgboost.DMatrix(
          it.as_array(),
          it.as_array_labels(),
          weight=it.as_array_weights(),
      )
  
      assert m_with_it.num_col() == m.num_col()
      assert m_with_it.num_row() == m.num_row()
      # Tree meethod must be `hist`.
      reg_with_it = xgboost.train(
          {"tree_method": "hist", "device": "cuda"},
          m_with_it,
          num_boost_round=rounds,
      )
      predict_with_it = reg_with_it.predict(m_with_it)
  
      reg = xgboost.train(
          {"tree_method": "hist", "device": "cuda"},
          m,
          num_boost_round=rounds,
      )
      predict = reg.predict(m)
  
      numpy.testing.assert_allclose(predict_with_it, predict, rtol=1e6)
  
file_path: xgboost/demo/guide-python/quantile_data_iterator.py
imports: import cupy
  import numpy
  import xgboost
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types