code: def _validate_model_id(
      store: mlmd.MetadataStore,
      model_type: metadata_store_pb2.ArtifactType,
      model_id: int,
  ) -> metadata_store_pb2.Artifact:
      """Validates the given `model_id` against the `store`.
  
      Args:
        store: A ml-metadata MetadataStore to be validated.
        model_type: The Model ArtifactType in the `store`.
        model_id: The id for the model artifact in the `store`.
  
      Returns:
        The model artifact with the id.
  
      Raises:
        ValueError: If the `model_id` cannot be resolved as a Model artifact in the
          given `store`.
      """
      model_artifacts = store.get_artifacts_by_id([model_id])
      if not model_artifacts:
          raise ValueError(
              f"Input model_id cannot be found: {model_id}."
          )
      model = model_artifacts[0]
      if model.type_id != model_type.id:
          raise ValueError(
              f"Found artifact with `model_id` is not an instance of Model: {model}."
          )
      return model
  
imports: import enum
  import os
  from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
  import attr
  import ml_metadata
  import tensorflow
  import tensorflow_model_analysis
  from absl import logging
  from ml_metadata.proto import metadata_store_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
  from model_card_toolkit import model_card
label_desc: Use image node_id 2 for calling a global function with example usage: _validate_model_id(store, model_type, model_id) and returns: model