code: def _get_id(artifact: metadata_store_pb2.Artifact) -> Any:
      """Get id for unique event generation per (execution, artifact)."""
      if artifact.id:
          return artifact.id
      # If artifact is resolved from external pipeline, it may not have a local
      # corresponding artifact entry thus lack an artifact ID, but there should be
      # a unique local artifact for the same external artifact, so we use this as
      # a fallback identifier of the artifact.
      if artifact.external_id:
          return artifact.external_id
      return None
  
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 12 for calling a global function with example usage: _get_id(artifact) and returns: None, artifact, artifact