parameters: (inputs, input_signature, flat_input_signature)
return_statement: return inputs
docstring: Convert inputs to pass into a function with an explicit signature.
docstring_summary: Convert inputs to pass into a function with an explicit signature.
docstring_tokens: Convert inputs to pass into a function with an explicit signature .
function: def _convert_inputs_to_signature(inputs, input_signature, flat_input_signature):
    """Convert inputs to pass into a function with an explicit signature."""
  
    def format_error_message(inputs, input_signature):
      return ("  inputs: (\n" + "    " +
              ",\n    ".join([str(i) for i in inputs]) + ")\n" +
              "  input_signature: (\n" + "    " +
              ",\n    ".join([str(i) for i in input_signature]) + ")")
  
    try:
      # TODO(b/124370185): Use all elements as inputs to throw an error if there
      # are ignored arguments. Calling with arguments that are not part of the
      # signature should throw an error.
      flatten_inputs = nest.flatten_up_to(
          input_signature,
          inputs[:len(input_signature)],
          expand_composites=True)
    except ValueError:
      raise ValueError("Structure of Python function inputs does not match "
                       "input_signature:\n%s" %
                       format_error_message(inputs, input_signature))
  
    need_packing = False
    for index, (value, spec) in enumerate(zip(flatten_inputs,
                                              flat_input_signature)):
      if not pywrap_tensorflow.IsTensor(value):
        try:
          flatten_inputs[index] = ops.convert_to_tensor(
              value, dtype_hint=spec.dtype)
          need_packing = True
        except ValueError:
          raise ValueError("When input_signature is provided, all inputs to "
                           "the Python function must be convertible to "
                           "tensors:\n%s" %
                           format_error_message(inputs, input_signature))
  
    if any(not spec.is_compatible_with(other) for spec, other in zip(
        flat_input_signature,
        flatten_inputs)):
      raise ValueError("Python inputs incompatible with input_signature:\n%s" %
                       format_error_message(inputs, input_signature))
  
    if need_packing:
      inputs = nest.pack_sequence_as(
          structure=input_signature,
          flat_sequence=flatten_inputs,
          expand_composites=True)
  
    return inputs
function_tokens: def _convert_inputs_to_signature ( inputs , input_signature , flat_input_signature ) : def format_error_message ( inputs , input_signature ) : return ( "  inputs: (\n" + "    " + ",\n    " . join ( [ str ( i ) for i in inputs ] ) + ")\n" + "  input_signature: (\n" + "    " + ",\n    " . join ( [ str ( i ) for i in input_signature ] ) + ")" ) try : # TODO(b/124370185): Use all elements as inputs to throw an error if there # are ignored arguments. Calling with arguments that are not part of the # signature should throw an error. flatten_inputs = nest . flatten_up_to ( input_signature , inputs [ : len ( input_signature ) ] , expand_composites = True ) except ValueError : raise ValueError ( "Structure of Python function inputs does not match " "input_signature:\n%s" % format_error_message ( inputs , input_signature ) ) need_packing = False for index , ( value , spec ) in enumerate ( zip ( flatten_inputs , flat_input_signature ) ) : if not pywrap_tensorflow . IsTensor ( value ) : try : flatten_inputs [ index ] = ops . convert_to_tensor ( value , dtype_hint = spec . dtype ) need_packing = True except ValueError : raise ValueError ( "When input_signature is provided, all inputs to " "the Python function must be convertible to " "tensors:\n%s" % format_error_message ( inputs , input_signature ) ) if any ( not spec . is_compatible_with ( other ) for spec , other in zip ( flat_input_signature , flatten_inputs ) ) : raise ValueError ( "Python inputs incompatible with input_signature:\n%s" % format_error_message ( inputs , input_signature ) ) if need_packing : inputs = nest . pack_sequence_as ( structure = input_signature , flat_sequence = flatten_inputs , expand_composites = True ) return inputs