code: def test_sparse_classification(
      sparse_container, expected_internal_type
  ):
      # Check classification with sparse input.
  
      class CustomSVC(SVC):
          """SVC variant that records the nature of the training set."""
  
          def fit(self, X, y, sample_weight=None):
              """Modification on fit caries data type for later verification."""
              super().fit(X, y, sample_weight=sample_weight)
              self.data_type_ = type(X)
              return self
  
      X, y = datasets.make_multilabel_classification(
          n_classes=1, n_samples=15, n_features=5, random_state=42
      )
      # Flatten y to a 1d array
      y = np.ravel(y)
  
      X_train, X_test, y_train, y_test = train_test_split(
          X, y, random_state=0
      )
  
      X_train_sparse = sparse_container(X_train)
      X_test_sparse = sparse_container(X_test)
  
      # Trained on sparse format
      sparse_classifier = AdaBoostClassifier(
          estimator=CustomSVC(probability=True),
          random_state=1,
          algorithm="SAMME",
      ).fit(X_train_sparse, y_train)
  
      # Trained on dense format
      dense_classifier = AdaBoostClassifier(
          estimator=CustomSVC(probability=True),
          random_state=1,
          algorithm="SAMME",
      ).fit(X_train, y_train)
  
      # predict
      sparse_clf_results = sparse_classifier.predict(X_test_sparse)
      dense_clf_results = dense_classifier.predict(X_test)
      assert_array_equal(sparse_clf_results, dense_clf_results)
  
      # decision_function
      sparse_clf_results = sparse_classifier.decision_function(
          X_test_sparse
      )
      dense_clf_results = dense_classifier.decision_function(X_test)
      assert_array_almost_equal(sparse_clf_results, dense_clf_results)
  
      # predict_log_proba
      sparse_clf_results = sparse_classifier.predict_log_proba(
          X_test_sparse
      )
      dense_clf_results = dense_classifier.predict_log_proba(X_test)
      assert_array_almost_equal(sparse_clf_results, dense_clf_results)
  
      # predict_proba
      sparse_clf_results = sparse_classifier.predict_proba(
          X_test_sparse
      )
      dense_clf_results = dense_classifier.predict_proba(X_test)
      assert_array_almost_equal(sparse_clf_results, dense_clf_results)
  
      # score
      sparse_clf_results = sparse_classifier.score(
          X_test_sparse, y_test
      )
      dense_clf_results = dense_classifier.score(X_test, y_test)
      assert_array_almost_equal(sparse_clf_results, dense_clf_results)
  
      # staged_decision_function
      sparse_clf_results = sparse_classifier.staged_decision_function(
          X_test_sparse
      )
      dense_clf_results = dense_classifier.staged_decision_function(
          X_test
      )
      for sparse_clf_res, dense_clf_res in zip(
          sparse_clf_results, dense_clf_results
      ):
          assert_array_almost_equal(sparse_clf_res, dense_clf_res)
  
      # staged_predict
      sparse_clf_results = sparse_classifier.staged_predict(
          X_test_sparse
      )
      dense_clf_results = dense_classifier.staged_predict(X_test)
      for sparse_clf_res, dense_clf_res in zip(
          sparse_clf_results, dense_clf_results
      ):
          assert_array_equal(sparse_clf_res, dense_clf_res)
  
      # staged_predict_proba
      sparse_clf_results = sparse_classifier.staged_predict_proba(
          X_test_sparse
      )
      dense_clf_results = dense_classifier.staged_predict_proba(X_test)
      for sparse_clf_res, dense_clf_res in zip(
          sparse_clf_results, dense_clf_results
      ):
          assert_array_almost_equal(sparse_clf_res, dense_clf_res)
  
      # staged_score
      sparse_clf_results = sparse_classifier.staged_score(
          X_test_sparse, y_test
      )
      dense_clf_results = dense_classifier.staged_score(X_test, y_test)
      for sparse_clf_res, dense_clf_res in zip(
          sparse_clf_results, dense_clf_results
      ):
          assert_array_equal(sparse_clf_res, dense_clf_res)
  
      # Verify sparsity of data is maintained during training
      types = [i.data_type_ for i in sparse_classifier.estimators_]
  
      assert all([t == expected_internal_type for t in types])
  
imports: import re
  import numpy
  import pytest
  from sklearn import datasets
  from sklearn.base import BaseEstimator, clone
  from sklearn.dummy import DummyClassifier, DummyRegressor
  from sklearn.ensemble import AdaBoostClassifier, AdaBoostRegressor
  from sklearn.ensemble._weight_boosting import _samme_proba
  from sklearn.linear_model import LinearRegression
  from sklearn.model_selection import GridSearchCV, train_test_split
  from sklearn.svm import SVC, SVR
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
  from sklearn.utils import shuffle
  from sklearn.utils._mocking import NoSampleWeightWrapper
  from sklearn.utils._testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less
  from sklearn.utils.fixes import COO_CONTAINERS, CSC_CONTAINERS, CSR_CONTAINERS, DOK_CONTAINERS, LIL_CONTAINERS
label_desc: Use image node_id 14 for calling a global function with example usage: test_sparse_classification(sparse_container, expected_internal_type) and returns: self