code: def subpipeline_ir_rewrite(
      original_ir: pipeline_pb2.Pipeline, execution_id: int
  ) -> pipeline_pb2.Pipeline:
      """Rewrites the subpipeline IR so that it can be run independently.
  
      Args:
        original_ir: Original subpipeline IR that is produced by compiler.
        execution_id: The ID of Subpipeline task scheduler Execution. It is used to
          generated a new pipeline run id.
  
      Returns:
        An updated subpipeline IR that can be run independently.
      """
      pipeline = copy.deepcopy(original_ir)
      pipeline.nodes[0].pipeline_node.ClearField("upstream_nodes")
      pipeline.nodes[-1].pipeline_node.ClearField("downstream_nodes")
      _update_pipeline_run_id(pipeline, execution_id)
      return pipeline
  
imports: import copy
  import threading
  from typing import Callable, Optional
  from absl import flags
  from absl import logging
  from tfx.orchestration import metadata
  from tfx.orchestration.experimental.core import pipeline_ops
  from tfx.orchestration.experimental.core import pipeline_state
  from tfx.orchestration.experimental.core import task
  from tfx.orchestration.experimental.core import task_scheduler
  from tfx.orchestration.portable.mlmd import context_lib
  from tfx.orchestration.portable.mlmd import execution_lib
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.utils import status
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: subpipeline_ir_rewrite(original_ir, execution_id) and returns: pipeline