class_docstr: Defines signatures to support regress and predict serving.
  
  This wraps the trained Keras model in two serving functions that can be saved
  with `tf.saved_model.save` or `model.save`, and loaded with corresponding
  signature names. The regress serving signature takes a batch of serialized
  `tf.Example`s as input, whereas the predict serving signature takes a batch of
  serialized `ExampleListWithContext` as input.
  
  Example usage:
  
  A ranking model can be saved with signatures as follows:
  
  ```python
  tf.saved_model.save(model, path, signatures=Signatures(model, ...)())
  ```
  
  For regress serving, scores can be generated using `REGRESS` signature as
  follows:
  
  ```python
  loaded_model = tf.saved_model.load(path)
  predictor = loaded_model.signatures[tf.saved_model.REGRESS_METHOD_NAME]
  scores = predictor(serialized_examples)[tf.saved_model.REGRESS_OUTPUTS]
  ```
  
  For predict serving, scores can be generated using `PREDICT` signature as
  follows:
  
  ```python
  loaded_model = tf.saved_model.load(path)
  predictor = loaded_model.signatures[tf.saved_model.PREDICT_METHOD_NAME]
  scores = predictor(serialized_elwcs)[tf.saved_model.PREDICT_OUTPUTS]
  ```
class_docstr_tok: ["Defines","signatures","to","support","regress","and","predict","serving",".","This","wraps","the","trained","Keras","model","in","two","serving","functions","that","can","be","saved","with","`","tf.saved_model.save","`","or","`","model.save","`",",","and","loaded","with","corresponding","signature","names",".","The","regress","serving","signature","takes","a","batch","of","serialized","`","tf.Example","`","s","as","input",",","whereas","the","predict","serving","signature","takes","a","batch","of","serialized","`","ExampleListWithContext","`","as","input",".","Example","usage",":","A","ranking","model","can","be","saved","with","signatures","as","follows",":","``","`","python","tf.saved_model.save","(","model",",","path",",","signatures=Signatures","(","model",",","...",")","(",")",")","``","`","For","regress","serving",",","scores","can","be","generated","using","`","REGRESS","`","signature","as","follows",":","``","`","python","loaded_model","=","tf.saved_model.load","(","path",")","predictor","=","loaded_model.signatures","[","tf.saved_model.REGRESS_METHOD_NAME","]","scores","=","predictor","(","serialized_examples",")","[","tf.saved_model.REGRESS_OUTPUTS","]","``","`","For","predict","serving",",","scores","can","be","generated","using","`","PREDICT","`","signature","as","follows",":","``","`","python","loaded_model","=","tf.saved_model.load","(","path",")","predictor","=","loaded_model.signatures","[","tf.saved_model.PREDICT_METHOD_NAME","]","scores","=","predictor","(","serialized_elwcs",")","[","tf.saved_model.PREDICT_OUTPUTS","]","``","`"]
docstr: Makes a tensorflow function for `predict`.
docstr_tok: ["Makes","a","tensorflow","function","for","`","predict","`","."]
code: def predict_tf_function(
      self,
  ) -> Callable[[tf.Tensor], Dict[str, tf.Tensor]]:
      """Makes a tensorflow function for `predict`."""
  
      @tf.function(
          input_signature=[
              tf.TensorSpec(
                  shape=[None],
                  dtype=tf.string,
                  name=tf.saved_model.PREDICT_INPUTS,
              )
          ]
      )
      def predict(serialized_elwcs: tf.Tensor) -> Dict[str, tf.Tensor]:
          """Defines predict signature."""
          features = data.parse_from_example_list(
              serialized_elwcs,
              context_feature_spec=self._context_feature_spec,
              example_feature_spec=self._example_feature_spec,
              mask_feature_name=self._mask_feature_name,
          )
          outputs = self._model(inputs=features, training=False)
          return self.normalize_outputs(
              tf.saved_model.PREDICT_OUTPUTS, outputs
          )
  
      return predict
  
file_path: ranking/tensorflow_ranking/python/keras/saved_model.py
imports: import functools
  from typing import Callable, Dict, Union
  import tensorflow
  from tensorflow_ranking.python import data
label_desc: Use image node_id 3 for calling the Signatures obj's underlying member method code with example usage: obj.predict_tf_function() and returns: predict, self