code: def test_predict_sparse(make_whas500):
      seed = 42
      whas500 = make_whas500(to_numeric=True)
      X, y = whas500.x, whas500.y
      # Duplicates values in whas500 leads to assert errors because of
      # tie resolution during tree fitting.
      # Using a synthetic dataset resolves this issue.
      X = np.random.RandomState(seed).binomial(n=5, p=0.1, size=X.shape)
  
      X_train, X_test, y_train, _ = train_test_split(
          X, y, random_state=seed
      )
  
      tree = SurvivalTree(min_samples_leaf=10, random_state=seed)
      tree.fit(X_train, y_train)
      y_pred = tree.predict(X_test)
      y_cum_h = tree.predict_cumulative_hazard_function(X_test)
      y_surv = tree.predict_survival_function(X_test)
  
      X_train_csr = sparse.csr_matrix(X_train)
      X_test_csr = sparse.csr_matrix(X_test)
  
      tree_csr = SurvivalTree(min_samples_leaf=10, random_state=seed)
      tree_csr.fit(X_train_csr, y_train)
      y_pred_csr = tree_csr.predict(X_test_csr)
      y_cum_h_csr = tree_csr.predict_cumulative_hazard_function(
          X_test_csr
      )
      y_surv_csr = tree_csr.predict_survival_function(X_test_csr)
  
      assert y_pred.shape[0] == X_test.shape[0]
      assert y_pred_csr.shape[0] == X_test.shape[0]
  
      assert_array_equal(y_pred, y_pred_csr)
      assert_array_equal(y_cum_h, y_cum_h_csr)
      assert_array_equal(y_surv, y_surv_csr)
  
imports: from itertools import product
  from queue import LifoQueue
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  import pandas
  import pytest
  from scipy import sparse
  from sklearn.model_selection import train_test_split
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import OrdinalEncoder
  from sklearn.tree._tree import TREE_UNDEFINED
  from sksurv.compare import compare_survival
  from sksurv.datasets import load_breast_cancer, load_veterans_lung_cancer
  from sksurv.nonparametric import kaplan_meier_estimator, nelson_aalen_estimator
  from sksurv.tree import SurvivalTree
  from sksurv.util import Surv
label_desc: Use image node_id 27 for calling a global function with example usage: test_predict_sparse(make_whas500) without return types