code: def test_apply_sparse(veterans):
      X, y = veterans
      X = X.loc[:, "Karnofsky_score"].values[:, np.newaxis]
      X = X.astype(np.float32)
      X_sparse = sparse.csr_matrix(X)
      tree = SurvivalTree(max_depth=2, max_features=1)
      tree.fit(X_sparse, y)
  
      X_trans = tree.apply(X_sparse)
  
      assert X_trans.shape[0] == X.shape[0]
      assert all(X_trans >= 0)
      assert all(X_trans < tree.tree_.node_count)
  
      X_path = tree.decision_path(X_sparse).toarray()
  
      assert X_path.shape[0] == X.shape[0]
      assert X_path.shape[1] == tree.tree_.node_count
  
      ones = X_path[np.arange(X.shape[0]), X_trans]
      assert_array_equal(ones, np.ones(X.shape[0]))
  
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 26 for calling a global function with example usage: test_apply_sparse(veterans) without return types