code: def _artifacts_to_garbage_collect_for_policy(
      artifacts: Sequence[metadata_store_pb2.Artifact],
      policy: garbage_collection_policy_pb2.GarbageCollectionPolicy,
  ) -> Sequence[metadata_store_pb2.Artifact]:
      """Returns artifacts that are not kept by the policy."""
      if policy.HasField("keep_most_recently_published"):
          return _artifacts_not_most_recently_published(
              artifacts, policy.keep_most_recently_published
          )
      elif policy.HasField("keep_property_value_groups"):
          return _artifacts_not_kept_by_property_value_groups(
              artifacts, policy.keep_property_value_groups
          )
      else:
          logging.error(
              "Skipped garbage collection due to unknown policy: %s",
              policy,
          )
          return []
  
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 4 for calling a global function with example usage: _artifacts_to_garbage_collect_for_policy(artifacts, policy) and returns: _artifacts_not_most_recently_published, _artifacts_not_kept_by_property_value_groups, list