code: def _do_inference(model_handle, examples_file, num_examples, schema):
      """Sends requests to the model and prints the results.
  
      Args:
        model_handle: handle to the model. This can be either
         "aiplatform:model:version" or "host:port"
        examples_file: path to csv file containing examples, with the first line
          assumed to have the column headers
        num_examples: number of requests to send to the server
        schema: a Schema describing the input data
  
      Returns:
        Response from model server
      """
      filtered_features = [
          feature
          for feature in schema.feature
          if feature.name != _LABEL_KEY
      ]
      del schema.feature[:]
      schema.feature.extend(filtered_features)
  
      proto_coder = _make_proto_coder(schema)
  
      csv_reader = csv.DictReader(open(examples_file, "r"))
  
      dataset_stats = tfdv.generate_statistics_from_csv(examples_file)
      serialized_examples = []
      for _ in range(num_examples):
          one_line = next(csv_reader)
          if not one_line:
              print("End of example file reached")
              break
          one_example = {}
          for feature in schema.feature:
              name = feature.name
              feature_stats = tfdv.get_feature_stats(
                  dataset_stats.datasets[0], tfdv.FeaturePath([name])
              )
              if one_line[name]:
                  if feature.type == schema_pb2.FLOAT:
                      one_example[name] = [float(one_line[name])]
                  elif feature.type == schema_pb2.INT:
                      one_example[name] = [int(one_line[name])]
                  elif feature.type == schema_pb2.BYTES:
                      one_example[name] = [
                          one_line[name].encode("utf8")
                      ]
              else:
                  # TF serve does not like missing features, so we'll populate
                  # the missing features with their mean/mode instead
                  if feature.type == schema_pb2.FLOAT:
                      one_example[name] = [feature_stats.num_stats.mean]
                  elif feature.type == schema_pb2.INT:
                      one_example[name] = [
                          int(feature_stats.num_stats.mean)
                      ]
                  elif feature.type == schema_pb2.BYTES:
                      top_values = list(
                          feature_stats.string_stats.top_values
                      )
                      if top_values:
                          one_example[name] = [
                              top_values[0].value.encode("utf8")
                          ]
                      else:
                          one_example[name] = ["".encode("utf8")]
  
          serialized_example = proto_coder.encode(one_example)
          serialized_examples.append(serialized_example)
  
      parsed_model_handle = model_handle.split(":")
      if parsed_model_handle[0] == "aiplatform":
          _do_aiplatform_inference(
              model=parsed_model_handle[1],
              version=parsed_model_handle[2],
              serialized_examples=serialized_examples,
          )
      else:
          _do_local_inference(
              host=parsed_model_handle[0],
              port=parsed_model_handle[1],
              serialized_examples=serialized_examples,
          )
  
imports: import argparse
  import base64
  import csv
  import json
  import os
  import subprocess
  import tempfile
  from typing import List
  from absl import app
  from absl.flags import argparse_flags
  import requests
  import tensorflow_data_validation
  from tensorflow_transform import coders
  from tensorflow_transform.tf_metadata import schema_utils
  from google.protobuf import text_format
  from tensorflow.python.lib.io import file_io
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 6 for calling a global function with example usage: _do_inference(model_handle, examples_file, num_examples, schema) without return types