Returns whether x is a SparseTensor or a parsed sparse tensor info.

def _is_sparse(x):
  """Returns whether x is a SparseTensor or a parsed sparse tensor info."""
  return (
      isinstance(x, (tf.SparseTensor, tf_v1.SparseTensorValue)) or
      (hasattr(x, "is_sparse") and x.is_sparse))