code: def garbage_collect_artifacts(
      mlmd_handle: metadata.Metadata,
      artifacts: Sequence[metadata_store_pb2.Artifact],
  ) -> None:
      """Garbage collect the artifacts by deleting the payloads.
  
      GC first filters out external artifacts, and all remaining internal artifacts
      will have distinct URIs. Therefore, it is valid to erase the file contents
      immediately, rather than setting the intermediate state (MARKED_FOR_DELETION)
      and waiting until all artifacts sharing the same URI are marked for deletion.
  
      Args:
        mlmd_handle: A handle to the MLMD db.
        artifacts: Artifacts that we want to erase their file contents for GC.
      """
      if not artifacts:
          return
      for artifact in artifacts:
          if _is_artifact_external(artifact):
              # To garbage collect external artifacts, only mark the artifacts as
              # DELETED in MLMD.
              logging.info(
                  "Mark external artifact %s as DELETED in MLMD",
                  artifact,
              )
              artifact.state = metadata_store_pb2.Artifact.State.DELETED
          else:
              # To garbage collect internal artifacts, delete the URIs and mark the
              # artifacts as DELETED in MLMD if deleting the URIs is successful.
              if _delete_artifact_uri(artifact):
                  logging.info(
                      "Mark internal artifact %s as DELETED in MLMD",
                      artifact,
                  )
                  artifact.state = (
                      metadata_store_pb2.Artifact.State.DELETED
                  )
  
      mlmd_handle.store.put_artifacts(artifacts)
  
imports: import collections
  import itertools
  from typing import Mapping, Optional, Sequence
  from absl import logging
  from tfx import types
  from tfx.dsl.io import fileio
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import metadata
  from tfx.orchestration import node_proto_view
  from tfx.orchestration.experimental.core import task
  from tfx.orchestration.portable.mlmd import event_lib
  from tfx.orchestration.portable.mlmd import execution_lib
  from tfx.orchestration.portable.mlmd import store_ext
  from tfx.proto.orchestration import garbage_collection_policy_pb2
  from tfx.orchestration.experimental.core import garbage_collection_extensions
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 12 for calling a global function with example usage: garbage_collect_artifacts(mlmd_handle, artifacts) without return types