code: def _reuse_existing_artifacts(
      artifacts: typing_utils.ArtifactMultiMap,
      existing_artifacts: typing_utils.ArtifactMultiMap,
  ) -> None:
      """Re-uses existing artifact IDs if they contain the same URIs."""
      if not _artifact_maps_contain_same_uris(
          artifacts, existing_artifacts
      ):
          raise ValueError(
              "Output artifacts were already registered for this execution, but with "
              "a different set of output artifacts."
              f"\nProvided artifacts:\n{artifacts}"
              f"\nExisting artifacts:\n{existing_artifacts}"
          )
  
      # The output maps have the same content so copy over existing artifact IDs.
      for key, existing_artifact_list in existing_artifacts.items():
          provided_artifact_list = artifacts[key]
          for existing_artifact in existing_artifact_list:
              for provided_artifact in provided_artifact_list:
                  if existing_artifact.uri == provided_artifact.uri:
                      provided_artifact.id = existing_artifact.id
                      provided_artifact.type_id = (
                          existing_artifact.type_id
                      )
                      break
  
imports: from __future__ import annotations
  import collections
  import copy
  import itertools
  import re
  from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple
  from absl import logging
  from tfx import types
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import metadata
  from tfx.orchestration.portable import outputs_utils
  from tfx.orchestration.portable.mlmd import artifact_lib
  from tfx.orchestration.portable.mlmd import common_utils
  from tfx.orchestration.portable.mlmd import event_lib
  from tfx.orchestration.portable.mlmd import filter_query_builder
  from tfx.utils import metrics_utils
  from tfx.proto.orchestration import execution_result_pb2
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.utils import proto_utils
  from tfx.utils import typing_utils
  from tfx.utils import telemetry_utils
  from google.protobuf import json_format
  import ml_metadata
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 18 for calling a global function with example usage: _reuse_existing_artifacts(artifacts, existing_artifacts) without return types