code: def export_serving_model(tf_transform_output, model, output_dir):
      """Exports a keras model for serving.
  
      Args:
        tf_transform_output: Wrapper around output of tf.Transform.
        model: A keras model to export for serving.
        output_dir: A directory where the model will be exported to.
      """
      # The layer has to be saved to the model for keras tracking purpases.
      model.tft_layer = tf_transform_output.transform_features_layer()
  
      @tf.function
      def serve_tf_examples_fn(serialized_tf_examples):
          """Serving tf.function model wrapper."""
          feature_spec = common.RAW_DATA_FEATURE_SPEC.copy()
          feature_spec.pop(common.LABEL_KEY)
          parsed_features = tf.io.parse_example(
              serialized_tf_examples, feature_spec
          )
          transformed_features = model.tft_layer(parsed_features)
          outputs = model(transformed_features)
          classes_names = tf.constant([["0", "1"]])
          classes = tf.tile(classes_names, [tf.shape(outputs)[0], 1])
          return {"classes": classes, "scores": outputs}
  
      concrete_serving_fn = serve_tf_examples_fn.get_concrete_function(
          tf.TensorSpec(shape=[None], dtype=tf.string, name="inputs")
      )
      signatures = {"serving_default": concrete_serving_fn}
  
      # This is required in order to make this model servable with model_server.
      versioned_output_dir = os.path.join(output_dir, "1")
      model.save(
          versioned_output_dir, save_format="tf", signatures=signatures
      )
  
file_path: transform/examples/census_example_v2.py
imports: import math
  import os
  import pprint
  import tempfile
  from absl import logging
  import tensorflow
  import tensorflow_transform
  import census_example_common
  from tensorflow_transform.keras_lib import tf_keras
label_desc: Use image node_id 3 for calling a global function with example usage: export_serving_model(tf_transform_output, model, output_dir) and returns: dict