code: def get_stats_artifacts_for_model(
      store: mlmd.MetadataStore,
      model_id: int,
      pipeline_types: Optional[PipelineTypes] = None,
  ) -> List[metadata_store_pb2.Artifact]:
      """Gets a list of statistics artifacts from a model artifact.
  
      It first looks for the input datasets of the trainer that produces the model.
      If the model uses a transformed examples, it further looks for the original
      dataset. Then it returns the statistics artifact of the found dataset(s).
  
      Args:
        store: A ml-metadata MetadataStore instance.
        model_id: The id for the model artifact in the `store`.
        pipeline_types: An optional set of types if the `store` uses custom types.
  
      Returns:
        A list of statistics artifacts produced by the StatsGen component runs
        for the datasets which are used to train the model.
  
      Raises:
        ValueError: If the `model_id` cannot be resolved as a model artifact in the
          given `store`.
      """
      if not pipeline_types:
          pipeline_types = _get_tfx_pipeline_types(store)
      _validate_model_id(store, pipeline_types.model_type, model_id)
      trainer_examples = _get_one_hop_artifacts(
          store,
          [model_id],
          _Direction.ANCESTOR,
          pipeline_types.dataset_type,
      )
      # If trainer takes transformed example, we look for its original dataset.
      dataset_ids = set()
      transformed_example_ids = set()
      for example in trainer_examples:
          if example.uri.find("/Transform/") != -1:
              transformed_example_ids.add(example.id)
          else:
              dataset_ids.add(example.id)
      dataset_ids.update(
          dataset.id
          for dataset in _get_one_hop_artifacts(
              store,
              transformed_example_ids,
              _Direction.ANCESTOR,
              pipeline_types.dataset_type,
          )
      )
      return _get_one_hop_artifacts(
          store,
          dataset_ids,
          _Direction.SUCCESSOR,
          pipeline_types.stats_type,
      )
  
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 6 for calling a global function with example usage: get_stats_artifacts_for_model(store, model_id, pipeline_types) and returns: _get_one_hop_artifacts