class_docstr: Bulk inferer executor for inference on AI Platform.
class_docstr_tok: ["Bulk","inferer","executor","for","inference","on","AI","Platform","."]
code: def _get_inference_spec(
      self,
      model_path: str,
      model_version: str,
      ai_platform_serving_args: Dict[str, Any],
  ) -> model_spec_pb2.InferenceSpecType:
      if "project_id" not in ai_platform_serving_args:
          raise ValueError(
              "`project_id` is missing in `ai_platform_serving_args`"
          )
      project_id = ai_platform_serving_args["project_id"]
      if "model_name" not in ai_platform_serving_args:
          raise ValueError(
              "`model_name` is missing in `ai_platform_serving_args`"
          )
      model_name = ai_platform_serving_args["model_name"]
      ai_platform_prediction_model_spec = (
          model_spec_pb2.AIPlatformPredictionModelSpec(
              project_id=project_id,
              model_name=model_name,
              version_name=model_version,
          )
      )
      model_signature = self._get_model_signature(model_path)
      if (
          len(model_signature.inputs) == 1
          and list(model_signature.inputs.values())[0].dtype
          == tf.string.as_datatype_enum
      ):
          ai_platform_prediction_model_spec.use_serialization_config = (
              True
          )
      logging.info(
          "Using hosted model on Cloud AI platform, model_name: %s,"
          "model_version: %s.",
          model_name,
          model_version,
      )
      result = model_spec_pb2.InferenceSpecType()
      result.ai_platform_prediction_model_spec.CopyFrom(
          ai_platform_prediction_model_spec
      )
      return result
  
imports: import hashlib
  import re
  from typing import Any, Dict, List
  from absl import logging
  from google.api_core import client_options
  from googleapiclient import discovery
  import tensorflow
  from tfx import types
  from tfx.components.bulk_inferrer import executor
  from tfx.components.util import model_utils
  from tfx.extensions.google_cloud_ai_platform import constants
  from tfx.extensions.google_cloud_ai_platform import runner
  from tfx.proto import bulk_inferrer_pb2
  from tfx.types import artifact_utils
  from tfx.utils import doc_controls
  from tfx.utils import json_utils
  from tfx.utils import name_utils
  from tfx.utils import path_utils
  from tfx.utils import proto_utils
  from tfx.utils import telemetry_utils
  from tfx_bsl.public.proto import model_spec_pb2
  from tensorflow.python.saved_model import loader_impl
label_desc: Use image node_id 2 for calling the Executor obj's underlying member method code with example usage: obj._get_inference_spec(model_path, model_version, ai_platform_serving_args) and returns: result