code: def testCheckStrictJsonCompat(self):
      for pair in (
          # Pairs are currently valid but not supported by is_json_compatible.
          (int, int),
          (List, List),
          (Dict, Dict),
          (List[str], List),
          (Dict[str, int], Dict),
          (Dict[str, float], Dict[str, float]),
          # Valid pairs are supported by is_json_compatible.
          (List[bool], List[bool]),
          (Dict[str, int], Union[Dict[str, int], List[int]]),
          (Dict[str, bool], Dict[str, Any]),
          (List[Dict[str, int]], List[Any]),
          (Dict[str, List[str]], Dict[str, Any]),
          (List[Dict[str, str]], List[Any]),
          (List[Any], List[Any]),
          (Dict[str, Any], Dict[str, Any]),
      ):
          self.assertTrue(check_strict_json_compat(pair[0], pair[1]))
  
      for pair in (
          (str, int),
          (Dict[str, int], Dict[str, str]),
          (Dict, Dict[str, int]),
          (List, List[float]),
          (type(None), int),
          (Dict[str, Any], Dict[str, str]),
          (Dict[str, str], List[Any]),
          (List[Any], List[Dict[str, bool]]),
          (List[Any], Dict[str, Any]),
      ):
          self.assertFalse(check_strict_json_compat(pair[0], pair[1]))
  
      # Runtime type check.
      self.assertTrue(
          check_strict_json_compat(
              {
                  "a": [1, 2, 3],
                  "b": [
                      3,
                  ],
                  "c": [1, 2, 3, 4],
              },
              Dict[str, List[int]],
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              {
                  "a": [1, 2, 3.0],
                  "b": [
                      3,
                  ],
                  "d": [1, 2, 3, 4],
              },
              Dict[str, List[Union[int, float]]],
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              {"a": {"b": True, "c": False}, "b": None},
              Dict[str, Optional[Dict[str, bool]]],
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              [1, {"a": True}, None, True, [3.0, 4.0]],
              List[
                  Optional[
                      Union[int, Dict[str, bool], List[float], bool]
                  ]
              ],
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              {"a": [1, 2, 3]},
              Union[List[int], Dict[str, List[int]], Dict[str, float]],
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              [1, 2, 3],
              Union[List[int], Dict[str, List[int]], Dict[str, float]],
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              {"a": 1.0},
              Union[List[int], Dict[str, List[int]], Dict[str, float]],
          )
      )
      self.assertTrue(check_strict_json_compat([1, 2, 3], List[Any]))
      self.assertTrue(check_strict_json_compat([], List[Any]))
      self.assertTrue(check_strict_json_compat({}, Dict[str, Any]))
      self.assertTrue(
          check_strict_json_compat(None, Optional[Dict[str, float]])
      )
      self.assertTrue(check_strict_json_compat([None, None], List[Any]))
      self.assertTrue(
          check_strict_json_compat([None, None], List[Optional[float]])
      )
      self.assertTrue(
          check_strict_json_compat({"a": 1.0, "b": True}, Dict)
      )
      self.assertTrue(
          check_strict_json_compat(
              {"a": {"a": 3}, "c": {"c": {"c": 1}}},
              Dict[str, Dict[str, Any]],
          )
      )
      self.assertTrue(
          check_strict_json_compat(None, Optional[Dict[str, int]])
      )
      self.assertTrue(
          check_strict_json_compat([1, 2], Optional[List[int]])
      )
      self.assertTrue(
          check_strict_json_compat([None], List[Optional[int]])
      )
      self.assertTrue(
          check_strict_json_compat(
              [[1, 2], [[3]], [4]], List[List[Union[List[int], int]]]
          )
      )
      self.assertTrue(
          check_strict_json_compat(
              {"a": 1.0, "b": 2.0}, Dict[str, float]
          )
      )
  
      self.assertFalse(
          check_strict_json_compat(
              {"a": [1, 2, 3.0]}, Dict[str, List[int]]
          )
      )
      self.assertFalse(
          check_strict_json_compat(
              {"a": {"b": True, "c": False}, "b": 1},
              Dict[str, Optional[Dict[str, bool]]],
          )
      )
      self.assertFalse(
          check_strict_json_compat(
              {"a": [True, False]},
              Union[List[int], Dict[str, List[int]], Dict[str, float]],
          )
      )
      self.assertFalse(
          check_strict_json_compat(
              [b"123"], List[Union[int, float, bool, str]]
          )
      )
      self.assertFalse(check_strict_json_compat({1: 2}, Dict[str, Any]))
      self.assertFalse(
          check_strict_json_compat(
              [{"a": b"b"}], Dict[str, Union[int, float, bool, str]]
          )
      )
      self.assertFalse(check_strict_json_compat(None, Dict[str, Any]))
      self.assertFalse(
          check_strict_json_compat(
              [1, 2], List[Union[str, float, bool]]
          )
      )
      self.assertFalse(
          check_strict_json_compat(
              {"a": True, "b": False}, Dict[str, Union[int, float, str]]
          )
      )
      self.assertFalse(
          check_strict_json_compat(
              {"a": {"a": 3}, "c": [1, 2]}, Dict[str, Dict[str, Any]]
          )
      )
      self.assertFalse(check_strict_json_compat({"a": 1}, List[Any]))
      self.assertFalse(check_strict_json_compat([1.0], Dict[str, Any]))
      self.assertFalse(
          check_strict_json_compat(
              {"a": True, "b": 2.0}, Dict[str, Union[int, float, str]]
          )
      )
  
file_path: tfx/tfx/dsl/component/experimental/json_compat_test.py
imports: from typing import Any, Dict, List, Optional, Union
  import tensorflow
  from tfx.dsl.component.experimental.json_compat import check_strict_json_compat
  from tfx.dsl.component.experimental.json_compat import is_json_compatible
label_desc: Use image node_id 2 for calling the JsonCompatTest obj's underlying member method code with example usage: obj.testCheckStrictJsonCompat() without return types