code: def testIsValidEvent_Path(self, event_type, is_valid_event):
      with self.subTest("No path."):
          self.assertFalse(
              is_valid_event(Event(type=event_type), "foo")
          )
  
      with self.subTest("Valid path."):
          self.assertTrue(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(key="foo"),
                              Step(index=0),
                          ]
                      ),
                  ),
                  "foo",
              )
          )
  
      with self.subTest("Key should match."):
          self.assertFalse(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(key="foo"),
                              Step(index=0),
                          ]
                      ),
                  ),
                  "bar",
              )
          )
  
      with self.subTest("Index does not matter."):
          self.assertTrue(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(key="foo"),
                              Step(index=123),
                          ]
                      ),
                  ),
                  "foo",
              )
          )
  
      with self.subTest("Multiple steps are ok"):
          self.assertTrue(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(key="asdf"),
                              Step(index=0),
                              Step(key="foo"),
                              Step(index=0),
                          ]
                      ),
                  ),
                  "foo",
              )
          )
  
      with self.subTest("Invalid path: len(steps) is odd."):
          self.assertFalse(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(key="asdf"),
                              Step(index=0),
                              Step(key="foo"),
                          ]
                      ),
                  ),
                  "foo",
              )
          )
  
      with self.subTest("Invalid path: steps[even] should be key."):
          self.assertFalse(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(index=0),
                              Step(key="foo"),
                          ]
                      ),
                  ),
                  "foo",
              )
          )
  
      with self.subTest("Invalid path: steps[odd] should be index."):
          self.assertFalse(
              is_valid_event(
                  Event(
                      type=event_type,
                      path=Path(
                          steps=[
                              Step(key="foo"),
                              Step(key="bar"),
                          ]
                      ),
                  ),
                  "foo",
              )
          )
  
imports: import itertools
  from absl.testing import parameterized
  import tensorflow
  from tfx.orchestration.portable.mlmd import event_lib
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 2 for calling the EventLibTest obj's underlying member method code with example usage: obj.testIsValidEvent_Path(event_type, is_valid_event) without return types