code: def update_artifacts(
      metadata_handle: metadata.Metadata,
      tfx_artifact_map: typing_utils.ArtifactMultiMap,
      new_artifact_state: Optional[str] = None,
  ) -> None:
      """Updates existing TFX artifacts in MLMD."""
      mlmd_artifacts_to_update = []
      for tfx_artifact in itertools.chain.from_iterable(
          tfx_artifact_map.values()
      ):
          if not tfx_artifact.mlmd_artifact.HasField("id"):
              raise ValueError(
                  "Artifact must have an MLMD ID in order to be updated."
              )
          if new_artifact_state:
              tfx_artifact.state = new_artifact_state
          mlmd_artifacts_to_update.append(tfx_artifact.mlmd_artifact)
      if mlmd_artifacts_to_update:
          metadata_handle.store.put_artifacts(mlmd_artifacts_to_update)
  
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 2 for calling a global function with example usage: update_artifacts(metadata_handle, tfx_artifact_map, new_artifact_state) without return types