code: def deploy_model_for_aip_prediction(
      serving_path: str,
      model_version_name: str,
      ai_platform_serving_args: Dict[str, Any],
      labels: Dict[str, str],
      api: Optional[discovery.Resource] = None,
      serving_container_image_uri: Optional[str] = None,
      endpoint_region: Optional[str] = None,
      skip_model_endpoint_creation: Optional[bool] = False,
      set_default: Optional[bool] = True,
      enable_vertex: Optional[bool] = False,
  ) -> str:
      """Deploys a model for serving with AI Platform.
  
      Args:
        serving_path: The path to the model. Must be a GCS URI.
        model_version_name: Model version for CAIP model being deployed, or model
          name for the Vertex model being deployed. Must be different from what is
          currently being served.
        ai_platform_serving_args: Dictionary containing arguments for pushing to AI
          Platform. The full set of parameters supported can be found at,
          for CAIP:
          https://cloud.google.com/ml-engine/reference/rest/v1/projects.models.versions#Version.
          for Vertex:
          https://googleapis.dev/python/aiplatform/latest/aiplatform.html?highlight=deploy#google.cloud.aiplatform.Model.deploy
            Most keys are forwarded as-is, but following keys are handled specially.
          For CAIP:
            - name: this must be empty (and will be filled by pusher).
            - deployment_uri: this must be empty (and will be filled by pusher).
            - python_version: when left empty, this will be filled by python version
              of the environment being used.
            - runtime_version: when left empty, this will be filled by TensorFlow
              version from the environment.
            - labels: a list of job labels will be merged with user's input.
          For Vertex:
            - endpoint_name: Name of the endpoint.
            - traffic_percentage: Desired traffic to newly deployed model. Forwarded
              as-is if specified. If not specified, it is set to 100 if
              set_default_version is True, or set to 0 otherwise.
            - labels: a list of job labels will be merged with user's input.
        labels: The dict of labels that will be attached to this CAIP job or Vertex
          endpoint. They are merged with optional labels from
          `ai_platform_serving_args`.
        api: (CAIP only, required) Google API client resource.
        serving_container_image_uri: (Vertex only, required) The path to the serving
          container image URI. Container registry for prediction is available at:
          https://gcr.io/cloud-aiplatform/prediction.
        endpoint_region: (Vertex only, required) Region for Vertex endpoint. For
          available regions, please see
          https://cloud.google.com/vertex-ai/docs/general/locations
        skip_model_endpoint_creation: If true, the method assumes CAIP model or
          Vertex endpoint already exists in AI platform, therefore skipping its
          creation.
        set_default: Whether set the newly deployed CAIP model version or Vertex
          model as the default.
        enable_vertex: Whether to enable Vertex or not.
  
      Returns:
        For Vertex, the resource name of the deployed model.
  
      Raises:
        RuntimeError: if an error is encountered when trying to push.
      """
      client = prediction_clients.get_prediction_client(
          api=api, enable_vertex=enable_vertex
      )
      if enable_vertex:
          return client.deploy_model(
              serving_path=serving_path,
              model_version_name=model_version_name,
              ai_platform_serving_args=ai_platform_serving_args,
              labels=labels,
              serving_container_image_uri=serving_container_image_uri,
              endpoint_region=endpoint_region,
              skip_model_endpoint_creation=skip_model_endpoint_creation,
              set_default=set_default,
          )
      else:
          return client.deploy_model(
              serving_path=serving_path,
              model_version_name=model_version_name,
              ai_platform_serving_args=ai_platform_serving_args,
              labels=labels,
              skip_model_endpoint_creation=skip_model_endpoint_creation,
              set_default=set_default,
          )
  
file_path: tfx/tfx/extensions/google_cloud_ai_platform/runner.py
imports: import time
  from typing import Any, Dict, List, Optional
  from absl import logging
  from googleapiclient import discovery
  from tfx import types
  from tfx.extensions.google_cloud_ai_platform import prediction_clients
  from tfx.extensions.google_cloud_ai_platform import training_clients
  from tfx.utils import version_utils
label_desc: Use image node_id 6 for calling a global function with example usage: deploy_model_for_aip_prediction(serving_path, model_version_name, ai_platform_serving_args, labels, api, serving_container_image_uri, endpoint_region, skip_model_endpoint_creation, set_default, enable_vertex) and returns: client, client