code: def _get_paths(
      metadata_connection: metadata.Metadata,
      executions: List[metadata_store_pb2.Execution],
      output_dir: str,
  ) -> Iterable[Tuple[str, str]]:
      """Yields tuple with source and destination artifact uris.
  
      The destination artifact uris are located in the output_dir. The source
      artifact uris are retrieved using execution ids. Artifact index is used
      for saving multiple output artifacts with same key.
  
      Args:
        metadata_connection: Instance of metadata.Metadata for I/O to MLMD.
        executions: List of executions of a pipeline run.
        output_dir: Directory path where the pipeline outputs should be recorded.
  
      Yields:
        Iterable over tuples of source uri and destination uri.
  
      Raises:
        ValueError if artifact key and index are not recorded in MLMD event.
      """
      for execution in executions:
          component_id = get_component_id_from_execution(
              metadata_connection, execution
          )
          if component_id.startswith("Resolver"):
              continue
          eid = [execution.id]
          events = (
              metadata_connection.store.get_events_by_execution_ids(eid)
          )
          output_events = [
              x
              for x in events
              if x.type == metadata_store_pb2.Event.OUTPUT
          ]
          for event in output_events:
              steps = event.path.steps
              if not steps or not steps[0].HasField("key"):
                  raise ValueError(
                      "Artifact key is not recorded in the MLMD."
                  )
              name = steps[0].key
              artifacts = metadata_connection.store.get_artifacts_by_id(
                  [event.artifact_id]
              )
              for artifact in artifacts:
                  src_uri = artifact.uri
                  if len(steps) < 2 or not steps[1].HasField("index"):
                      raise ValueError(
                          "Artifact index is not recorded in the MLMD."
                      )
                  artifact_index = steps[1].index
                  dest_uri = os.path.join(
                      output_dir,
                      component_id,
                      name,
                      str(artifact_index),
                  )
                  yield (src_uri, dest_uri)
  
file_path: tfx/tfx/experimental/pipeline_testing/pipeline_recorder_utils.py
imports: import collections
  import os
  from typing import Iterable, List, Mapping, Optional, Tuple
  from absl import logging
  from tfx.dsl.compiler import constants
  from tfx.orchestration import metadata
  from tfx.utils import io_utils
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _get_paths(metadata_connection, executions, output_dir) without return types