def split_long_token(token_string,
                     max_output_token_length):
  """Splits a token losslessly to some maximum length per component.

  A long token is split into multiple tokens. For instance, `'bcd'` with
  `max_output_token_length=2` will become `['bc', 'd']`. No sentinel or other
  split mark is added at this stage.

  A token is assumed to be non-empty.

  Args:
    token_string: The token.
    max_output_token_length: Maximum length of an output token.

  Returns:
    List of split tokens.

  Raises:
    ValueError: if `token` is empty.
  """
  if not token_string:
    raise ValueError('Expected %r to be non-empty' % token_string)

  whole_token_length = len(token_string)
  remainder_length = whole_token_length % max_output_token_length
  even_parts = list(
      map(
          # ...join together...
          ''.join,
          zip(
              # `max_output_token_length` copies of the iterator of
              # whole_token's characters. zip will draw from the same iterator
              # and return `max_output_token_length` tuples of characters from
              # `whole_token`.
              *[iter(token_string)] * max_output_token_length)))
  remainder_part = ([token_string[-remainder_length:]]
                    if remainder_length else [])
  split_token = even_parts + remainder_part
  assert split_token, ('while wrapping >>%s<< into >%r<' %
                       (token_string, split_token))
  assert all([
      len(t) <= max_output_token_length for t in split_token
  ]), ('Got split_token >>>%r<<<, which contains tokens longer than %d.' %
       (split_token, max_output_token_length))
  return split_token