code: def get_artifacts_to_garbage_collect_for_node(
      mlmd_handle: metadata.Metadata,
      node_uid: task_lib.NodeUid,
      node: node_proto_view.NodeProtoView,
  ) -> Sequence[metadata_store_pb2.Artifact]:
      """Returns output artifacts of the given node to garbage collect."""
      policies_by_output_key = (
          _get_garbage_collection_policies_for_node(node)
      )
      logging.info(
          "Garbage collection policies for node %s: %s",
          node.node_info.id,
          policies_by_output_key,
      )
      if not policies_by_output_key:
          return []
  
      artifacts_by_output_key = _get_live_output_artifacts_for_node(
          mlmd_handle, node_uid
      )
      if not artifacts_by_output_key:
          return []
      logging.info(
          "Candidate artifacts to garbage collect for node %s : %s",
          node.node_info.id,
          artifacts_by_output_key,
      )
  
      dedupped_artifact_ids = set()
      for artifact in itertools.chain.from_iterable(
          artifacts_by_output_key.values()
      ):
          dedupped_artifact_ids.add(artifact.id)
  
      events = mlmd_handle.store.get_events_by_artifact_ids(
          dedupped_artifact_ids
      )
  
      result = []
      for output_key, policy in policies_by_output_key.items():
          if output_key not in artifacts_by_output_key:
              continue
          artifacts_to_garbage_collect_for_output_key = (
              _artifacts_to_garbage_collect(
                  mlmd_handle,
                  artifacts_by_output_key[output_key],
                  events,
                  policy,
              )
          )
          result.extend(artifacts_to_garbage_collect_for_output_key)
          logging.info(
              "Artifacts to garbage collect for output key %s: %s",
              output_key,
              artifacts_to_garbage_collect_for_output_key,
          )
      return result
  
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 11 for calling a global function with example usage: get_artifacts_to_garbage_collect_for_node(mlmd_handle, node_uid, node) and returns: result, list, list