code: def _write_tfx_artifacts(
      mlmd_handle: metadata.Metadata,
      tfx_artifacts: Sequence[types.Artifact],
  ) -> Sequence[int]:
      """Writes TFX artifacts to MLMD and updates their IDs in-place."""
      artifact_type_id = mlmd_handle.store.put_artifact_type(
          artifact_type=metadata_store_pb2.ArtifactType(
              name=_DEFAULT_ARTIFACT_TYPE.TYPE_NAME
          )
      )
      for tfx_artifact in tfx_artifacts:
          tfx_artifact.type_id = artifact_type_id
  
      created_artifact_ids = mlmd_handle.store.put_artifacts(
          [tfx_artifact.mlmd_artifact for tfx_artifact in tfx_artifacts]
      )
      for idx, artifact_id in enumerate(created_artifact_ids):
          tfx_artifacts[idx].id = artifact_id
      return created_artifact_ids
  
file_path: tfx/tfx/orchestration/portable/mlmd/artifact_lib_test.py
imports: from typing import Optional, Sequence
  import tensorflow
  from tfx import types
  from tfx.orchestration import metadata
  from tfx.orchestration.portable.mlmd import artifact_lib
  from tfx.types import standard_artifacts
  from tfx.utils import test_case_utils
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _write_tfx_artifacts(mlmd_handle, tfx_artifacts) and returns: created_artifact_ids