def _to_tensor(t):
  """Converts value to a tensor if possible; otherwise, returns the original."""
  try:
    return tf.convert_to_tensor(t)
  except TypeError:
    return t
Converts value to a tensor if possible; otherwise, returns the original.
language/canine/tensor_contracts.py