message: Also format all related ValueError when input and input_signature are needed
diff: @@ -1521,6 +1521,12 @@ def _convert_numpy_inputs(inputs):
  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
  @@ -1531,8 +1537,8 @@ def _convert_inputs_to_signature(inputs, input_signature, flat_input_signature):
  expand_composites=True)
  except ValueError:
  raise ValueError("Structure of Python function inputs does not match "
  - "input_signature. Inputs (%s), input_signature(%s)." %
  - (str(inputs), str(input_signature)))
  + "input_signature:\n" %
  + format_error_message(inputs, input_signature))
  need_packing = False
  for index, (value, spec) in enumerate(zip(flatten_inputs,
  @@ -1544,16 +1550,10 @@ def _convert_inputs_to_signature(inputs, input_signature, flat_input_signature):
  need_packing = True
  except ValueError:
  raise ValueError("When input_signature is provided, all inputs to "
  - "the Python function must be convertible to tensors."
  - "Inputs (%s), input_signature(%s)." %
  - (str(inputs), str(input_signature)))
  + "the Python function must be convertible to "
  + "tensors:\n" %
  + format_error_message(inputs, 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]) +
  - ")")
  if any(not spec.is_compatible_with(other) for spec, other in zip(
  flat_input_signature,
  flatten_inputs)):
  