code: def delete_model_from_aip_if_exists(
      ai_platform_serving_args: Dict[str, Any],
      api: Optional[discovery.Resource] = None,
      model_version_name: Optional[str] = None,
      delete_model_endpoint: Optional[bool] = False,
      enable_vertex: Optional[bool] = False,
  ) -> None:
      """Deletes a model version from Google Cloud AI Platform if version exists.
  
      Args:
        ai_platform_serving_args: Dictionary containing arguments for pushing to AI
          Platform. For the full set of parameters supported, refer to
          https://cloud.google.com/ml-engine/reference/rest/v1/projects.models
        api: (CAIP only, required) Google API client resource.
        model_version_name: Model version for CAIP model being deployed, or model
          name for the Vertex model to be deleted. Required if delete_model_endpoint
          is False, otherwise not needed.
        delete_model_endpoint: Whether CAIP model or Vertex endpoint should be
          deleted.
        enable_vertex: Whether to enable Vertex or not.
  
      Raises:
        RuntimeError: if an error is encountered when trying to delete.
      """
      client = prediction_clients.get_prediction_client(
          api=api, enable_vertex=enable_vertex
      )
      client.delete_model_from_aip_if_exists(
          ai_platform_serving_args=ai_platform_serving_args,
          model_version_name=model_version_name,
          delete_model_endpoint=delete_model_endpoint,
      )
  
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 7 for calling a global function with example usage: delete_model_from_aip_if_exists(ai_platform_serving_args, api, model_version_name, delete_model_endpoint, enable_vertex) without return types