code: def build(cls, seqs: Iterable[int], uid: bool = False) -> 'SequenceSet':
          
          seqs_list = sorted(set(seqs))
          groups: List[Union[int, Tuple[int, int]]] = []
          group: Union[int, Tuple[int, int]] = seqs_list[0]
          for i in range(1, len(seqs_list)):
              group_i = seqs_list[i]
              if isinstance(group, int):
                  if group_i == group + 1:
                      group = (group, group_i)
                  else:
                      groups.append(group)
                      group = group_i
              elif isinstance(group, tuple):
                  if group_i == group[1] + 1:
                      group = (group[0], group_i)
                  else:
                      groups.append(group)
                      group = group_i
          groups.append(group)
          return SequenceSet(groups, uid)
docs: Build a new sequence set that contains the given values using as
          few groups as possible.
  
          Args:
              seqs: The sequence values to build.
              uid: True if the sequences refer to message UIDs.