code: def _artifacts_not_most_recently_published(
      artifacts: Sequence[metadata_store_pb2.Artifact],
      keep_most_recently_published: garbage_collection_policy_pb2.GarbageCollectionPolicy.KeepMostRecentlyPublished,
  ) -> Sequence[metadata_store_pb2.Artifact]:
      """Returns artifacts that are not kept by KeepMostRecentlyPublished."""
      num_artifacts = keep_most_recently_published.num_artifacts
      if num_artifacts <= 0:
          return artifacts
      elif len(artifacts) <= num_artifacts:
          return []
      else:
          # Handle ties if multiple artifacts have the same create_time_since_epoch
          publish_times = sorted(
              [a.create_time_since_epoch for a in artifacts]
          )
          cutoff_publish_time = publish_times[-num_artifacts]
          return [
              a
              for a in artifacts
              if a.create_time_since_epoch < cutoff_publish_time
          ]
  
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 5 for calling a global function with example usage: _artifacts_not_most_recently_published(artifacts, keep_most_recently_published) and returns: artifacts, list, unknown