code: def get_artifacts_by_ids(
      metadata_handle: metadata.Metadata, artifact_ids: Sequence[int]
  ) -> Sequence[types.Artifact]:
      """Gets TFX artifacts from MLMD by ID.
  
      Args:
        metadata_handle: A handler to access MLMD.
        artifact_ids: The IDs of existing artifacts to query.
  
      Returns:
        A list of the deserialized TFX artifacts.
  
      Raises:
        ValueError if one or more of the artifact IDs does not exist in MLMD.
      """
      (
          mlmd_artifacts,
          artifact_types,
      ) = metadata_handle.store.get_artifacts_and_types_by_artifact_ids(
          artifact_ids
      )
      if len(artifact_ids) != len(mlmd_artifacts):
          raise ValueError(
              f"Could not find all MLMD artifacts for ids: {artifact_ids}"
          )
  
      # Create a map keyed by artifact type id.
      artifact_types_by_id = {a.id: a for a in artifact_types}
  
      # Set `type` field in the artifact proto which is not filled by MLMD.
      for mlmd_artifact in mlmd_artifacts:
          mlmd_artifact.type = artifact_types_by_id[
              mlmd_artifact.type_id
          ].name
  
      # Return a list with MLMD artifacts deserialized to TFX Artifact instances.
      return [
          artifact_utils.deserialize_artifact(
              artifact_types_by_id[mlmd_artifact.type_id], mlmd_artifact
          )
          for mlmd_artifact in mlmd_artifacts
      ]
  
file_path: tfx/tfx/orchestration/portable/mlmd/artifact_lib.py
imports: import itertools
  from typing import Optional, Sequence
  from tfx import types
  from tfx.orchestration import metadata
  from tfx.utils import metrics_utils
  from tfx.types import artifact_utils
  from tfx.utils import typing_utils
  from tfx.utils import telemetry_utils
label_desc: Use image node_id 1 for calling a global function with example usage: get_artifacts_by_ids(metadata_handle, artifact_ids) and returns: unknown