code: def is_valid_output_event(
      event: metadata_store_pb2.Event,
      expected_output_key: Optional[str] = None,
  ) -> bool:
      """Evaluates whether an event is an output event with the right output key.
  
      This function only returns true if the event type produces a finalized output,
      which excludes events of type PENDING_OUTPUT.
  
      Args:
        event: The event to evaluate.
        expected_output_key: The expected output key.
  
      Returns:
        A bool value indicating result
      """
      if event.type not in _VALID_OUTPUT_EVENT_TYPES:
          return False
      if expected_output_key:
          return contains_key(event, expected_output_key)
      return True
  
file_path: tfx/tfx/orchestration/portable/mlmd/event_lib.py
imports: import collections
  import contextlib
  from typing import Dict, List, Optional, Sequence, Tuple, TypeVar
  from tfx import types
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 5 for calling a global function with example usage: is_valid_output_event(event, expected_output_key) and returns: True, False, contains_key