code: def _get_runtime_parameter_value(
      runtime_parameter: pipeline_pb2.RuntimeParameter,
      parameter_bindings: Mapping[str, types.Property],
  ) -> Optional[types.Property]:
      """Populates the value for a RuntimeParameter when possible.
  
      If external parameter bindings not found, try to use the default value.
  
      Args:
        runtime_parameter: RuntimeParameter as the template.
        parameter_bindings: Parameter bindings to substitute runtime parameter
          placeholders in the RuntimeParameter.
  
      Returns:
        Resolved value for the RuntimeParameter if available. Returns None if the
        RuntimeParameter cannot be resolved.
  
      Raises:
        RuntimeError: When the provided binding value type does not match the
          RuntimeParameter type requirement.
      """
      # If no external parameter bindings for this runtime parameter, try to use its
      # default value.
      if runtime_parameter.name not in parameter_bindings:
          if runtime_parameter.HasField("default_value"):
              default_value = getattr(
                  runtime_parameter.default_value,
                  runtime_parameter.default_value.WhichOneof("value"),
              )
              if _is_type_match(runtime_parameter.type, default_value):
                  return default_value
              else:
                  raise RuntimeError(
                      "Runtime parameter type %s does not match with %s."
                      % (type(default_value), runtime_parameter)
                  )
          else:
              return None
  
      # External parameter binding is found, try to use it.
      binding_value = parameter_bindings[runtime_parameter.name]
      if _is_type_match(runtime_parameter.type, binding_value):
          return binding_value
      else:
          raise RuntimeError(
              "Runtime parameter type %s does not match with %s."
              % (type(binding_value), runtime_parameter)
          )
  
file_path: tfx/tfx/orchestration/portable/runtime_parameter_utils.py
imports: from typing import Mapping, Optional, cast, Dict
  from tfx import types
  from tfx.orchestration import data_types_utils
  from tfx.proto.orchestration import pipeline_pb2
  from google.protobuf import descriptor
  from google.protobuf import message
label_desc: Use image node_id 2 for calling a global function with example usage: _get_runtime_parameter_value(runtime_parameter, parameter_bindings) and returns: binding_value, None, default_value