code: def test_SparseTensorType_filter():
      y = sp_matrix("csc", dtype="float64", name="y")
      z = sp_matrix("csr", dtype="float64", name="z")
      w = sp_matrix("csr", dtype="float32", name="z")
  
      with pytest.raises(TypeError, match="Expected an array-like"):
          y.type.filter(dmatrix())
  
      x = sp.sparse.csc_matrix(sp.sparse.eye(5, 3))
      x_res = y.type.filter(x)
      assert x is x_res
  
      x_res = z.type.filter(x)
      assert x_res.format == "csr"
  
      with pytest.raises(TypeError):
          x_res = z.type.filter(x, strict=True)
  
      x_res = w.type.filter(x, allow_downcast=True)
      assert x_res.dtype == "float32"
  
      x_res = z.type.filter(x.astype("float32"), allow_downcast=True)
      assert x_res.dtype == "float64"
  
      with pytest.raises(TypeError, match=".*dtype but got.*"):
          w.type.filter(x)
  
file_path: pytensor/tests/sparse/test_type.py
imports: import pytest
  import scipy
  from pytensor.sparse import matrix
  from pytensor.sparse.type import SparseTensorType
  from pytensor.tensor import dmatrix
label_desc: Use image node_id 4 for calling a global function with example usage: test_SparseTensorType_filter() without return types