code: def _delete_artifact_uri(
      artifact: metadata_store_pb2.Artifact,
  ) -> bool:
      """Deletes the artifact's URI and returns True if it can be marked as DELETED.
  
      Args:
        artifact: The artifact containing the URI to delete.
  
      Returns:
        True: If the URI is deleted or does not exist. In this case we can safely
          mark the artifact as DELETED in MLMD.
        False: If deleting the artifact URI fails.
      """
      logging.info("Deleting URI %s", artifact.uri)
  
      try:
          if fileio.isdir(artifact.uri):
              fileio.rmtree(artifact.uri)
          else:
              fileio.remove(artifact.uri)
          return True
  
      # TODO(kmonte): See if there's some fileio exception list we can catch.
      except Exception:  # pylint: disable=broad-exception-caught
          # If an exception is raised during deletion, there are several cases:
          #
          # Case 1: The artifact URI does not exist (if it has been TTL'd off disk,
          # etc.), and in this case the artifact should still be marked as DELETED.
          #
          # Case 2: The artifact URI exists but removing it still fails (if permission
          # is denied, etc.), and in this case the artifact should not be marked as
          # DELETED.
          #
          # Note that even in Case 2, `fileio` may still raise a FileNotFoundError. So
          # instead of catching FileNotFoundError, we check if the URI does not exit.
          if not fileio.exists(artifact.uri):
              logging.exception(
                  "URI %s not found for artifact %s",
                  artifact.uri,
                  artifact,
              )
              return True
  
          logging.exception("Failed to delete artifact %s", artifact)
          return False
  
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 10 for calling a global function with example usage: _delete_artifact_uri(artifact) and returns: True, False, True