code: def resolve_execution_mode(tfx_pipeline: pipeline.Pipeline):
      """Resolves execution mode for a tfx pipeline.
  
      Args:
        tfx_pipeline: a TFX pipeline python object assembled by SDK.
  
      Returns:
        a proto enum reflecting the execution mode of the pipeline.
  
      Raises:
        RuntimeError: when execution mode is ASYNC while `enable_cache` is true.
        ValueError: when seeing unrecognized execution mode.
      """
      if tfx_pipeline.execution_mode == pipeline.ExecutionMode.SYNC:
          return pipeline_pb2.Pipeline.ExecutionMode.SYNC
      elif tfx_pipeline.execution_mode == pipeline.ExecutionMode.ASYNC:
          if tfx_pipeline.enable_cache:
              raise RuntimeError(
                  "Caching is a feature only available to synchronous execution pipelines."
              )
          return pipeline_pb2.Pipeline.ExecutionMode.ASYNC
      else:
          raise ValueError(
              f"Got unsupported execution mode: {tfx_pipeline.execution_mode}"
          )
  
imports: from typing import cast, List, Optional, Sequence, Tuple, Type, Union, Dict, Any, Set
  from tfx import types
  from tfx.dsl.compiler import constants
  from tfx.dsl.components.base import base_node
  from tfx.dsl.components.common import importer
  from tfx.dsl.components.common import resolver
  from tfx.dsl.context_managers import dsl_context_registry
  from tfx.dsl.placeholder import placeholder
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import pipeline
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.types import channel
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: resolve_execution_mode(tfx_pipeline) and returns: pipeline_pb2, pipeline_pb2