code: def get_latest_executions(
      metadata_connection: metadata.Metadata, pipeline_name: str
  ) -> List[metadata_store_pb2.Execution]:
      """Fetches executions associated with the latest context.
  
      Args:
        metadata_connection: Instance of metadata.Metadata for I/O to MLMD.
        pipeline_name: Name of the pipeline to rerieve the latest executions for.
  
      Returns:
        List of executions for the latest run of a pipeline with the given
        pipeline_name.
      """
      store = metadata_connection.store
      pipeline_context = store.get_context_by_type_and_name(
          "pipeline", pipeline_name
      )
      if pipeline_context is None:
          raise ValueError(
              f"Cannot find any execution for {pipeline_name}"
          )
  
      # Sort all pipeline run contexts and find first pipeline run for the pipeline.
      pipeline_run_contexts = sorted(
          store.get_contexts_by_type("pipeline_run"),
          key=lambda c: c.last_update_time_since_epoch,
          reverse=True,
      )
  
      executions_for_pipeline = store.get_executions_by_context(
          pipeline_context.id
      )
      execution_ids_for_pipeline = {
          e.id for e in executions_for_pipeline
      }
      for pipeline_run_context in pipeline_run_contexts:
          executions_for_pipelin_run = store.get_executions_by_context(
              pipeline_run_context.id
          )
          if (
              executions_for_pipelin_run
              and executions_for_pipelin_run[0].id
              in execution_ids_for_pipeline
          ):
              return executions_for_pipelin_run
  
      raise ValueError(f"Cannot find any execution for {pipeline_name}")
  
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 4 for calling a global function with example usage: get_latest_executions(metadata_connection, pipeline_name) and returns: executions_for_pipelin_run