code: def testUnionChecker(self):
      int_checker = dispatch.MakeInstanceChecker(int)
      float_checker = dispatch.MakeInstanceChecker(float)
      str_checker = dispatch.MakeInstanceChecker(str)
      none_checker = dispatch.MakeInstanceChecker(type(None))
      tensor_checker = dispatch.MakeInstanceChecker(tensor.Tensor)
      ragged_checker = dispatch.MakeInstanceChecker(
          ragged_tensor.RaggedTensor
      )
  
      t = constant_op.constant([1, 2, 3])
      rt = ragged_factory_ops.constant([[1, 2], [3, 4, 5]])
  
      with self.subTest("Union[int, float, str]"):
          checker = dispatch.MakeUnionChecker(
              [int_checker, float_checker, str_checker]
          )
          self.assertEqual(checker.Check(3), MATCH)
          self.assertEqual(checker.Check(3.0), MATCH)
          self.assertEqual(checker.Check("x"), MATCH)
          self.assertEqual(checker.Check("x"), MATCH)
          self.assertEqual(checker.Check(None), NO_MATCH)
          self.assertEqual(checker.Check(t), NO_MATCH)
          self.assertEqual(checker.cost(), 4)
          self.assertEqual(
              repr(checker), "<PyTypeChecker Union[int, float, str]>"
          )
  
      with self.subTest("Optional[int] (aka Union[int, None])"):
          checker = dispatch.MakeUnionChecker(
              [int_checker, none_checker]
          )
          self.assertEqual(checker.Check(3), MATCH)
          self.assertEqual(checker.Check(3.0), NO_MATCH)
          self.assertEqual(checker.Check(None), MATCH)
          self.assertEqual(checker.Check(t), NO_MATCH)
          self.assertEqual(checker.cost(), 3)
          self.assertEqual(
              repr(checker), "<PyTypeChecker Union[int, NoneType]>"
          )
  
      with self.subTest("Union[Tensor, RaggedTensor]"):
          checker = dispatch.MakeUnionChecker(
              [tensor_checker, ragged_checker]
          )
          self.assertEqual(checker.Check(3), NO_MATCH)
          self.assertEqual(checker.Check(3.0), NO_MATCH)
          self.assertEqual(checker.Check(None), NO_MATCH)
          self.assertEqual(checker.Check(t), MATCH)
          self.assertEqual(checker.Check(rt), MATCH_DISPATCHABLE)
          self.assertEqual(checker.cost(), 3)
          self.assertEqual(
              repr(checker),
              "<PyTypeChecker Union[Tensor, RaggedTensor]>",
          )
  
imports: import collections
  import numpy
  from tensorflow.python.framework import _pywrap_python_api_dispatcher
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 3 for calling the PythonTypeCheckerTest obj's underlying member method code with example usage: obj.testUnionChecker() without return types