code: def test_check_array_accept_sparse_type_exception():
      X = [[1, 2], [3, 4]]
      X_csr = sp.csr_matrix(X)
  
      msg = (
          "A sparse tensor was passed, but dense data is required. "
          "Use X.todense() to convert to a dense tensor."
      )
      assert_raise_message(
          TypeError, msg, check_array, X_csr, accept_sparse=False
      )
  
      msg = (
          "When providing 'accept_sparse' as a tuple or list, "
          "it must contain at least one string value."
      )
      assert_raise_message(
          ValueError,
          msg.format([]),
          check_array,
          X_csr,
          accept_sparse=[],
      )
      assert_raise_message(
          ValueError,
          msg.format(()),
          check_array,
          X_csr,
          accept_sparse=(),
      )
  
      with pytest.raises(ValueError):
          check_array(X_csr, accept_sparse=object)
  
imports: from itertools import product
  import numpy
  import pytest
  import scipy.sparse
  from sklearn.utils.estimator_checks import _NotAnArray
  from sklearn.utils._mocking import MockDataFrame
  from sklearn.utils._testing import assert_raise_message, assert_raises_regex
  from ....None import tensor
  from ....None import dataframe
  from ....tensor.core import Tensor
  from ..validation import check_array, check_consistent_length
label_desc: Use image node_id 5 for calling a global function with example usage: test_check_array_accept_sparse_type_exception() without return types