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: Returns a dict of Tensors for outputs.
  
  Args:
    default_key: If outputs is a Tensor, use the default_key to make a dict.
    outputs: outputs to be normalized.
  
  Returns:
    A dict maps from str-like key(s) to Tensor(s).
  
  Raises:
    TypeError if outputs is not a Tensor nor a dict.
docstr_tok: ["Returns","a","dict","of","Tensors","for","outputs",".","Args",":","default_key",":","If","outputs","is","a","Tensor",",","use","the","default_key","to","make","a","dict",".","outputs",":","outputs","to","be","normalized",".","Returns",":","A","dict","maps","from","str-like","key","(","s",")","to","Tensor","(","s",")",".","Raises",":","TypeError","if","outputs","is","not","a","Tensor","nor","a","dict","."]
code: def normalize_outputs(
      self,
      default_key: str,
      outputs: Union[tf.Tensor, Dict[str, tf.Tensor]],
  ) -> Dict[str, tf.Tensor]:
      """Returns a dict of Tensors for outputs.
  
      Args:
        default_key: If outputs is a Tensor, use the default_key to make a dict.
        outputs: outputs to be normalized.
  
      Returns:
        A dict maps from str-like key(s) to Tensor(s).
  
      Raises:
        TypeError if outputs is not a Tensor nor a dict.
      """
      if isinstance(outputs, tf.Tensor):
          return {default_key: outputs}
      elif isinstance(outputs, dict):
          return outputs
      else:
          raise TypeError(
              "Model outputs need to be either a tensor or a dict of tensors."
          )
  
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 2 for calling the Signatures obj's underlying member method code with example usage: obj.normalize_outputs(default_key, outputs) and returns: dict, outputs