code: def _register_pending_output_artifacts(
      metadata_handle: metadata.Metadata,
      execution: metadata_store_pb2.Execution,
      output_artifacts: typing_utils.ArtifactMultiMap,
  ) -> None:
      """Registers PENDING output artifacts for a given execution in MLMD."""
      pending_output_artifacts = collections.defaultdict(list)
      for key, artifacts in output_artifacts.items():
          for artifact in artifacts:
              # Only consider artifacts not in state REFERENCE.
              if artifact.state != ArtifactState.REFERENCE:
                  artifact.state = ArtifactState.PENDING
                  pending_output_artifacts[key].append(artifact)
  
      # Find existing registered artifacts (that are not in state REFERENCE) with a
      # PENDING_OUTPUT event and re-use them.
      valid_artifact_states = metadata_store_pb2.Artifact.State.values()
      valid_artifact_states.remove(
          metadata_store_pb2.Artifact.State.REFERENCE
      )
      existing_pending_output_artifacts = get_pending_output_artifacts(
          metadata_handle, execution.id, valid_artifact_states
      )
      if existing_pending_output_artifacts:
          _reuse_existing_artifacts(
              pending_output_artifacts,
              existing_pending_output_artifacts,
          )
  
      elif pending_output_artifacts:
          # Register the pending output artifacts for this execution.
          contexts = metadata_handle.store.get_contexts_by_execution(
              execution.id
          )
          put_execution(
              metadata_handle,
              execution,
              contexts,
              output_artifacts=pending_output_artifacts,
              output_event_type=metadata_store_pb2.Event.PENDING_OUTPUT,
          )
  
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 20 for calling a global function with example usage: _register_pending_output_artifacts(metadata_handle, execution, output_artifacts) without return types