code: def get_pipeline_outputs(
      metadata_connection_config: Optional[
          metadata_store_pb2.ConnectionConfig
      ],
      pipeline_name: str,
  ) -> Dict[str, Dict[str, Dict[int, types.Artifact]]]:
      """Returns a dictionary of pipeline output artifacts for every component.
  
      Args:
        metadata_connection_config: connection configuration to MLMD.
        pipeline_name: Name of the pipeline.
  
      Returns:
        a dictionary of holding list of artifacts for a component id.
      """
      output_map = {}
      with metadata.Metadata(metadata_connection_config) as m:
          executions = pipeline_recorder_utils.get_latest_executions(
              m, pipeline_name
          )
          for execution in executions:
              component_id = pipeline_recorder_utils.get_component_id_from_execution(
                  m, execution
              )
              output_dict = {}
              for event in m.store.get_events_by_execution_ids(
                  [execution.id]
              ):
                  if event.type == metadata_store_pb2.Event.OUTPUT:
                      artifacts = m.store.get_artifacts_by_id(
                          [event.artifact_id]
                      )
                      steps = event.path.steps
                      if not steps or not steps[0].HasField("key"):
                          raise ValueError(
                              "Artifact key is not recorded in the MLMD."
                          )
                      key = steps[0].key
                      artifacts = m.store.get_artifacts_by_id(
                          [event.artifact_id]
                      )
                      if key not in output_dict:
                          output_dict[key] = {}
                      for pb_artifact in artifacts:
                          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
                          if artifact_index in output_dict[key]:
                              raise ValueError(
                                  "Artifact already in output_dict"
                              )
                          [
                              artifact_type
                          ] = m.store.get_artifact_types_by_id(
                              [pb_artifact.type_id]
                          )
                          artifact = (
                              artifact_utils.deserialize_artifact(
                                  artifact_type, pb_artifact
                              )
                          )
                          output_dict[key][artifact_index] = artifact
              output_map[component_id] = output_dict
      return output_map
  
imports: import filecmp
  import os
  from typing import Dict, List, Optional
  from absl import logging
  import tensorflow_model_analysis
  from tfx import types
  from tfx.dsl.io import fileio
  from tfx.experimental.pipeline_testing import pipeline_recorder_utils
  from tfx.orchestration import metadata
  from tfx.types import artifact_utils
  from tfx.utils import io_utils
  from ml_metadata.proto import metadata_store_pb2
  from tensorflow_metadata.proto.v0 import anomalies_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: get_pipeline_outputs(metadata_connection_config, pipeline_name) and returns: output_map