code: def test_filter_variable():
      test_type = TensorType(config.floatX, shape=())
  
      with pytest.raises(TypeError):
          test_type.filter(test_type())
  
      test_type = TensorType(config.floatX, shape=(1, None))
  
      with pytest.raises(TypeError):
          test_type.filter(np.empty((0, 1), dtype=config.floatX))
  
      with pytest.raises(TypeError, match=".*not aligned.*"):
          test_val = np.empty((1, 2), dtype=config.floatX)
          test_val.flags.aligned = False
          test_type.filter(test_val)
  
      with pytest.raises(ValueError, match="Non-finite"):
          test_type.filter_checks_isfinite = True
          test_type.filter(np.full((1, 2), np.inf, dtype=config.floatX))
  
      test_type2 = TensorType(config.floatX, shape=(None, None))
      test_var = test_type()
      test_var2 = test_type2()
  
      res = test_type.filter_variable(test_var, allow_convert=True)
      assert res is test_var
  
      # Make sure it returns the more specific type
      res = test_type.filter_variable(test_var2, allow_convert=True)
      assert res.type == test_type
  
      test_type3 = TensorType(config.floatX, shape=(1, 20))
      res = test_type3.filter_variable(test_var, allow_convert=True)
      assert res.type == test_type3
  
imports: import os.path
  from tempfile import mkdtemp
  import numpy
  import pytest
  import pytensor.tensor
  from pytensor.configdefaults import config
  from pytensor.tensor.shape import SpecifyShape
  from pytensor.tensor.type import TensorType, col, matrix, row, scalar, tensor, tensor3, tensor4, tensor5, tensor6, tensor7, vector
label_desc: Use image node_id 6 for calling a global function with example usage: test_filter_variable() without return types