code: def register_context_if_not_exists(
      metadata_handle: metadata.Metadata,
      context_type_name: str,
      context_name: str,
      parent_contexts: Optional[
          List[metadata_store_pb2.Context]
      ] = None,
  ) -> metadata_store_pb2.Context:
      """Registers a context if not exist, otherwise returns the existing one.
  
      This is a simplified wrapper around the method above which only takes context
      type and context name.
  
      Args:
        metadata_handle: A handler to access MLMD store.
        context_type_name: The name of the context type.
        context_name: The name of the context.
        parent_contexts: Optional. If it is provided, will set the new context as a
          child of the parent contexts.
  
      Returns:
        An MLMD context.
      """
      context_spec = pipeline_pb2.ContextSpec(
          name=pipeline_pb2.Value(
              field_value=metadata_store_pb2.Value(
                  string_value=context_name
              )
          ),
          type=metadata_store_pb2.ContextType(name=context_type_name),
      )
      return _register_context_if_not_exist(
          metadata_handle=metadata_handle,
          context_spec=context_spec,
          parent_contexts=parent_contexts,
      )
  
file_path: tfx/tfx/orchestration/portable/mlmd/context_lib.py
imports: from typing import List, Optional
  from absl import logging
  from tfx.dsl.compiler import constants
  from tfx.orchestration import data_types_utils
  from tfx.orchestration import metadata
  from tfx.orchestration.portable.mlmd import common_utils
  from tfx.utils import metrics_utils
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.utils import telemetry_utils
  import ml_metadata
  from ml_metadata import errors
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: register_context_if_not_exists(metadata_handle, context_type_name, context_name, parent_contexts) and returns: _register_context_if_not_exist