code: def _put_type_handler(
      get_type_handler: Any,
      put_type_handler: Any,
      metadata_type: MetadataType,
  ) -> MetadataType:
      """register the type with error handling.
  
      Args:
        get_type_handler: A handler to access MLMD store.
        put_type_handler: A handler to access MLMD store.
        metadata_type: The metadata type to register if does not exist.
  
      Returns:
        A MetadataType with id
  
      Raises:
        RuntimeError: If new metadata type conflicts with existing schema in MLMD.
        ValueError: If metadata type is not expected.
      """
      try:
          put_type_handler(
              metadata_type, can_add_fields=True, can_omit_fields=True
          )
          return get_type_handler(metadata_type.name)
      except mlmd.errors.AlreadyExistsError as exc:
          existing_type = get_type_handler(metadata_type.name)
          assert existing_type is not None, (
              "Not expected to get None when getting type %s."
              % metadata_type.name
          )
          warning_str = (
              "Conflicting properties comparing with existing metadata type "
              "with the same type name. Existing type: "
              "%s, New type: %s, error: %s"
          ) % (existing_type, metadata_type, exc)
          logging.warning(warning_str)
          raise RuntimeError(warning_str) from exc
  
file_path: tfx/tfx/orchestration/portable/mlmd/common_utils.py
imports: import copy
  from typing import Any, TypeVar
  from absl import logging
  from tfx.orchestration import metadata
  import ml_metadata
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: _put_type_handler(get_type_handler, put_type_handler, metadata_type) and returns: get_type_handler