code: def to_runtime_artifact(
      artifact_instance: artifact.Artifact,
      name_from_id: Mapping[int, str],
  ) -> pipeline_pb2.RuntimeArtifact:
      """Converts TFX artifact instance to RuntimeArtifact proto message."""
      metadata = struct_pb2.Struct()
      json_format.ParseDict(
          _get_json_metadata_mapping(artifact_instance), metadata
      )
      result = pipeline_pb2.RuntimeArtifact(
          uri=artifact_instance.uri, metadata=metadata
      )
      # TODO(b/135056715): Change to a unified getter/setter of Artifact type
      # once it's ready.
      # Try convert tfx artifact id to string-typed name. This should be the case
      # when running on an environment where metadata access layer is not running
      # in user space.
      id_or_none = getattr(artifact_instance, "id", None)
      if id_or_none is not None and id_or_none in name_from_id:
          result.name = name_from_id[id_or_none]
      else:
          logging.warning(
              "Cannot convert ID back to runtime name for artifact %s",
              artifact_instance,
          )
      return result
  
imports: import hashlib
  from typing import Any, Dict, List, Mapping, MutableMapping, Optional
  from absl import logging
  from kfp.pipeline_spec import pipeline_spec_pb2
  from tfx.components.evaluator import constants
  from tfx.orchestration.kubeflow.v2 import compiler_utils
  from tfx.types import artifact
  from tfx.types import artifact_utils
  from tfx.types import standard_component_specs
  from tfx.utils import import_utils
  import yaml
  from google.protobuf import struct_pb2
  from google.protobuf import json_format
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 9 for calling a global function with example usage: to_runtime_artifact(artifact_instance, name_from_id) and returns: result