code: def reconstruct_inputs_and_outputs(
      artifacts: Sequence[_Artifact],
      events: Sequence[metadata_store_pb2.Event],
  ) -> Tuple[_ArtifactMultiDict, _ArtifactMultiDict]:
      """Reconstructs input and output artifact maps from events."""
      execution_ids = {event.execution_id for event in events}
      if len(execution_ids) > 1:
          raise ValueError(
              "All events should be from the same execution but got: "
              f"{execution_ids}."
          )
  
      input_events = [
          e for e in events if e.type in _VALID_INPUT_EVENT_TYPES
      ]
      output_events = [
          e for e in events if e.type in _VALID_OUTPUT_EVENT_TYPES
      ]
      return (
          reconstruct_artifact_multimap(artifacts, input_events),
          reconstruct_artifact_multimap(artifacts, output_events),
      )
  
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 4 for calling a global function with example usage: reconstruct_inputs_and_outputs(artifacts, events) and returns: reconstruct_artifact_multimap,  reconstruct_artifact_multimap