code: def test_CheckAndRaise_sparse_variable():
      check_and_raise = CheckAndRaise(ValueError, "sparse_check")
  
      spe1 = scipy.sparse.csc_matrix(scipy.sparse.eye(5, 3))
      aspe1 = as_sparse_variable(spe1)
      a1 = check_and_raise(aspe1, aspe1.sum() > 2)
      assert a1.sum().eval() == 3
  
      spe2 = scipy.sparse.csc_matrix(scipy.sparse.eye(5, 1))
      aspe2 = as_sparse_variable(spe2)
      a2 = check_and_raise(aspe1, aspe2.sum() > 2)
      with pytest.raises(ValueError, match="sparse_check"):
          a2.sum().eval()
  
imports: import numpy
  import pytest
  import scipy.sparse
  import pytensor
  import pytensor.tensor
  from pytensor.compile.mode import OPT_FAST_RUN, Mode
  from pytensor.graph import vectorize_graph
  from pytensor.graph.basic import Constant, equal_computations
  from pytensor.raise_op import Assert, CheckAndRaise, assert_op
  from pytensor.scalar.basic import ScalarType, float64
  from pytensor.sparse import as_sparse_variable
  from pytensor.tensor.basic import second
  from pytensor.tensor.elemwise import DimShuffle
  from tests import unittest_tools
label_desc: Use image node_id 7 for calling a global function with example usage: test_CheckAndRaise_sparse_variable() without return types