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: Constructor.
  
  Args:
    model: A Keras ranking model.
    context_feature_spec: (dict) A mapping from feature keys to
      `FixedLenFeature` or `RaggedFeature` values for context in
      `tensorflow.serving.ExampleListWithContext` proto.
    example_feature_spec: (dict) A mapping from feature keys to
      `FixedLenFeature` or `Ragged` values for examples in
      `tensorflow.serving.ExampleListWithContext` proto.
    mask_feature_name: (str) Name of feature for example list masks.
docstr_tok: ["Constructor",".","Args",":","model",":","A","Keras","ranking","model",".","context_feature_spec",":","(","dict",")","A","mapping","from","feature","keys","to","`","FixedLenFeature","`","or","`","RaggedFeature","`","values","for","context","in","`","tensorflow.serving.ExampleListWithContext","`","proto",".","example_feature_spec",":","(","dict",")","A","mapping","from","feature","keys","to","`","FixedLenFeature","`","or","`","Ragged","`","values","for","examples","in","`","tensorflow.serving.ExampleListWithContext","`","proto",".","mask_feature_name",":","(","str",")","Name","of","feature","for","example","list","masks","."]
code: def __init__(
      self,
      model: tf.keras.Model,
      context_feature_spec: Dict[
          str, Union[tf.io.FixedLenFeature, tf.io.RaggedFeature]
      ],
      example_feature_spec: Dict[
          str, Union[tf.io.FixedLenFeature, tf.io.RaggedFeature]
      ],
      mask_feature_name: str,
  ):
      """Constructor.
  
      Args:
        model: A Keras ranking model.
        context_feature_spec: (dict) A mapping from feature keys to
          `FixedLenFeature` or `RaggedFeature` values for context in
          `tensorflow.serving.ExampleListWithContext` proto.
        example_feature_spec: (dict) A mapping from feature keys to
          `FixedLenFeature` or `Ragged` values for examples in
          `tensorflow.serving.ExampleListWithContext` proto.
        mask_feature_name: (str) Name of feature for example list masks.
      """
      super().__init__()
      self._model = model
      self._context_feature_spec = context_feature_spec
      self._example_feature_spec = example_feature_spec
      self._mask_feature_name = mask_feature_name
  
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 1 to create a new Signatures object from inherited base classes: tf with example: obj = Signatures(model, context_feature_spec, example_feature_spec, mask_feature_name)