def _unique_length(elements):
  """Calculate the unique length of the provided elements.

  Args:
    elements: iterable of objects with a defined length.

  Returns:
    Integer unique length.

  Raises:
    ValueError: if there is no unique length, or if the iterable is empty.
  """
  lengths = set(len(elem) for elem in elements)
  if not lengths:
    raise ValueError('no sequences provided')
  length = lengths.pop()
  if lengths:
    raise ValueError('sequences to cluster must have a unique length')
  return length