def _is_tensor(t) -> bool:
  """Returns true if the value is a tensor or can be converted to a tensor."""
  if tf.is_tensor(t):
    return True
  try:
    tf.convert_to_tensor(t)
    return True
  except:  # pylint: disable=bare-except
    # Usually a `TypeError`, but we can occasionally get other strange
    # conversion errors such as non-descript `ValueError`s. Any failure here
    # is definitely due to not being converible to a tensor.
    return False
Returns true if the value is a tensor or can be converted to a tensor.
language/canine/tensor_contracts.py