parameters: (model, input_signature=None)
return_statement: return _wrapped_model
docstring: Trace the model call to create a tf.function for exporting a Keras model.
  
    Args:
      model: A Keras model.
      input_signature: optional, a list of tf.TensorSpec objects specifying the
        inputs to the model.
  
    Returns:
      A tf.function wrapping the model's call function with input signatures set.
  
    Raises:
      ValueError: if input signature cannot be inferred from the model.
docstring_summary: Trace the model call to create a tf.function for exporting a Keras model.
docstring_tokens: Trace the model call to create a tf . function for exporting a Keras model .
function: def trace_model_call(model, input_signature=None):
    """Trace the model call to create a tf.function for exporting a Keras model.
  
    Args:
      model: A Keras model.
      input_signature: optional, a list of tf.TensorSpec objects specifying the
        inputs to the model.
  
    Returns:
      A tf.function wrapping the model's call function with input signatures set.
  
    Raises:
      ValueError: if input signature cannot be inferred from the model.
    """
    if input_signature is None and isinstance(model.call, def_function.Function):
      input_signature = model.call.input_signature
  
    @def_function.function(input_signature=input_signature, autograph=False)
    def _wrapped_model(*args):
      """A concrete tf.function that wraps the model's call function."""
      # When given a single input, Keras models will call the model on the tensor
      # rather than a list consisting of the single tensor.
      # inputs = args[0] if len(input_signature) == 1 else list(args)
      inputs = args[0] if len(args) == 1 else list(args)
  
      with base_layer_utils.call_context().enter(
          model, inputs=inputs, build_graph=False, training=False, saving=True):
        return model(*args, training=False)
        #outputs_list = nest.flatten(model(*args, training=False))
  
      #try:
      #  output_names = model.output_names
      #except AttributeError:
      #  from tensorflow.python.keras.engine import training_utils  # pylint: disable=g-import-not-at-top
      #  output_names = training_utils.generic_output_names(outputs_list)
      #return {name: output for name, output in zip(output_names, outputs_list)}
  
    return _wrapped_model
function_tokens: def trace_model_call ( model , input_signature = None ) : if input_signature is None and isinstance ( model . call , def_function . Function ) : input_signature = model . call . input_signature @ def_function . function ( input_signature = input_signature , autograph = False ) def _wrapped_model ( * args ) : """A concrete tf.function that wraps the model's call function.""" # When given a single input, Keras models will call the model on the tensor # rather than a list consisting of the single tensor. # inputs = args[0] if len(input_signature) == 1 else list(args) inputs = args [ 0 ] if len ( args ) == 1 else list ( args ) with base_layer_utils . call_context ( ) . enter ( model , inputs = inputs , build_graph = False , training = False , saving = True ) : return model ( * args , training = False ) #outputs_list = nest.flatten(model(*args, training=False)) #try: #  output_names = model.output_names #except AttributeError: #  from tensorflow.python.keras.engine import training_utils  # pylint: disable=g-import-not-at-top #  output_names = training_utils.generic_output_names(outputs_list) #return {name: output for name, output in zip(output_names, outputs_list)} return _wrapped_model