def _printable_tensor(t):
  """Formats tensor (potentially ragged) so that it can be printed in Assert."""
  if isinstance(t, tf.RaggedTensor):
    # Convert to a string so that it's obvious that padding positions aren't
    # just regular values.
    return tf.strings.as_string(t).to_tensor()
  else:
    return t
Formats tensor (potentially ragged) so that it can be printed in Assert.
language/canine/tensor_contracts.py