code: def test_params_type_filtering(self):
      shape_tensor5 = (1, 2, 2, 3, 2)
      size_tensor5 = (
          shape_tensor5[0]
          * shape_tensor5[1]
          * shape_tensor5[2]
          * shape_tensor5[3]
          * shape_tensor5[4]
      )
      random_tensor = np.random.normal(size=size_tensor5).reshape(
          shape_tensor5
      )
  
      w = ParamsType(
          a1=TensorType("int32", (False, False)),
          a2=TensorType("float64", (False, False, False, False, False)),
          a3=Generic(),
      )
  
      # With a value that does not match the params type.
      o = Params(
          w,
          a1=np.asarray(
              [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
          ).astype("int64"),
          a2=random_tensor.astype("float32"),
          a3=2000,
      )
      # should fail (o.a1 is not int32, o.a2 is not float64)
      self.assertRaises(TypeError, w.filter, o, True)
      # should fail (o.a1 is not int32, o.a2 is not float64, and downcast is disallowed)
      self.assertRaises(TypeError, w.filter, o, False, False)
      # Should pass.
      w.filter(o, strict=False, allow_downcast=True)
  
      # With a value that matches the params type.
      o1 = Params(
          w,
          a1=np.asarray(
              [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
          ).astype("int32"),
          a2=random_tensor.astype("float64"),
          a3=2000,
      )
      # All should pass.
      w.filter(o1, strict=True)
      w.filter(o1, strict=False, allow_downcast=False)
      w.filter(o1, strict=False, allow_downcast=True)
  
      # Check values_eq and values_eq_approx.
      o2 = Params(
          w,
          a1=np.asarray(
              [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
          ).astype("int32"),
          a2=random_tensor.astype("float64"),
          a3=2000,
      )
      assert w.values_eq(o1, o2)
      assert w.values_eq_approx(o1, o2)
  
      # Check value_eq_approx.
      # NB: I don't know exactly which kind of differences is rejected by values_eq but accepted by values_eq_approx.
      # So, I just play a little with float values.
      o3 = Params(
          w,
          a1=np.asarray(
              [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
          ).astype("int32"),
          a2=(
              random_tensor.astype("float32")
              * 10
              / 2.2
              * 2.19999999999
              / 10
          ).astype("float64"),
          a3=2000.0 - 0.00000000000000001,
      )
      assert w.values_eq_approx(o1, o3)
  
imports: from __future__ import absolute_import, print_function, division
  import theano
  import numpy
  from unittest import TestCase
  from theano.gof import Op, COp, Apply
  from theano import Generic
  from theano.scalar import Scalar
  from theano.tensor import TensorType
  from theano.gof import ParamsType, Params, EnumList
  from theano import tensor
  from theano.tests import unittest_tools
label_desc: Use image node_id 3 for calling the TestParamsType obj's underlying member method code with example usage: obj.test_params_type_filtering() without return types