code: def test_unary(self, method, exp_type, cm, x):
      if x is None:
          x = pt.dmatrix("x")
  
      x = sparse.csr_from_dense(x)
  
      method_to_call = getattr(x, method)
  
      if cm is None:
          cm = pytest.warns(UserWarning, match=".*converted to dense.*")
  
      if exp_type == SparseTensorType:
          exp_res_type = csr_matrix
      else:
          exp_res_type = np.ndarray
  
      with cm:
          z = method_to_call()
  
      if not isinstance(z, tuple):
          z_outs = (z,)
      else:
          z_outs = z
  
      assert all(isinstance(out.type, exp_type) for out in z_outs)
  
      f = pytensor.function(
          [x], z, on_unused_input="ignore", allow_input_downcast=True
      )
  
      res = f([[1.1, 0.0, 2.0], [-1.0, 0.0, 0.0]])
  
      if not isinstance(res, list):
          res_outs = [res]
      else:
          res_outs = res
  
      assert all(isinstance(out, exp_res_type) for out in res_outs)
  
file_path: pytensor/tests/sparse/test_var.py
imports: from contextlib import ExitStack
  import numpy
  import pytest
  from scipy.sparse.csr import csr_matrix
  import pytensor
  import pytensor.sparse
  import pytensor.tensor
  from pytensor.sparse.type import SparseTensorType
  from pytensor.tensor.type import DenseTensorType
label_desc: Use image node_id 1 for calling the TestSparseVariable obj's underlying member method code with example usage: obj.test_unary(method, exp_type, cm, x) without return types