code: def call_servo(examples, serving_bundle):
      """Send an RPC request to the Servomatic prediction service.
  
      Args:
        examples: A list of examples that matches the model spec.
        serving_bundle: A `ServingBundle` object that contains the information to
          make the serving request.
  
      Returns:
        A ClassificationResponse or RegressionResponse proto.
      """
      # Batch size for number of examples to send to servo in a single RPC.
      batch_size = 100000
  
      parsed_url = urlparse(
          "http://" + serving_bundle.inference_address
      )
      channel = implementations.insecure_channel(
          parsed_url.hostname, parsed_url.port
      )
      stub = prediction_service_pb2.beta_create_PredictionService_stub(
          channel
      )
  
      def batch_call(batch_examples):
          if serving_bundle.use_predict:
              request = predict_pb2.PredictRequest()
          elif serving_bundle.model_type == "classification":
              request = classification_pb2.ClassificationRequest()
          else:
              request = regression_pb2.RegressionRequest()
          request.model_spec.name = serving_bundle.model_name
          if serving_bundle.model_version is not None:
              request.model_spec.version.value = (
                  serving_bundle.model_version
              )
          if serving_bundle.signature is not None:
              request.model_spec.signature_name = (
                  serving_bundle.signature
              )
  
          if serving_bundle.use_predict:
              # tf.compat.v1 API used here to convert tf.example into proto. This
              # utility file is bundled in the witwidget pip package which has a dep
              # on TensorFlow.
              request.inputs[
                  serving_bundle.predict_input_tensor
              ].CopyFrom(
                  tf.compat.v1.make_tensor_proto(
                      values=[
                          ex.SerializeToString()
                          for ex in batch_examples
                      ],
                      dtype=types_pb2.DT_STRING,
                  )
              )
          else:
              request.input.example_list.examples.extend(batch_examples)
  
          if serving_bundle.use_predict:
              return common_utils.convert_predict_response(
                  stub.Predict(request, 30.0), serving_bundle
              )  # 30 secs timeout
          elif serving_bundle.model_type == "classification":
              return stub.Classify(request, 30.0)  # 30 secs timeout
          else:
              return stub.Regress(request, 30.0)  # 30 secs timeout
  
      start_example = 0
      results = []
      first_loop = True
      while start_example < len(examples) or first_loop:
          first_loop = False
          end_example = start_example + batch_size
          batch_examples = examples[start_example:end_example]
          results.append(batch_call(batch_examples))
          start_example = end_example
      return combine_results(
          results, serving_bundle.model_type == "classification"
      )
  
file_path: what-if-tool/utils/platform_utils.py
imports: import csv
  from glob import glob
  from grpc.beta import implementations
  import os
  import random
  from six.moves.urllib.parse import urlparse
  import tensorflow
  from utils import common_utils
  from tensorflow.core.framework import types_pb2
  from tensorflow_serving.apis import classification_pb2
  from tensorflow_serving.apis import predict_pb2
  from tensorflow_serving.apis import prediction_service_pb2
  from tensorflow_serving.apis import regression_pb2
label_desc: Use image node_id 5 for calling a global function with example usage: call_servo(examples, serving_bundle) and returns: combine_results, common_utils, stub, stub