docs: def _generate_subtokens(
      token_counts, alphabet, min_count, num_iterations=4,
      reserved_tokens=None):
    """Create a list of subtokens in decreasing order of frequency.
  
    Args:
      token_counts: dict mapping str tokens -> int count
      alphabet: set of characters
      min_count: int minimum number of times a subtoken must appear before it is
        added to the vocabulary.
      num_iterations: int number of iterations to generate new tokens.
      reserved_tokens: list of tokens that will be added to the beginning to the
        returned subtoken list.
  
    Returns:
      Sorted list of subtokens (most frequent first)
    """
    if reserved_tokens is None:
      reserved_tokens = RESERVED_TOKENS
  
    # Use alphabet set to create initial list of subtokens
    subtoken_list = reserved_tokens + list(alphabet)
    max_subtoken_length = 1
  
    # On each iteration, segment all words using the subtokens defined in
    # subtoken_dict, count how often the resulting subtokens appear, and update
    # the dictionary with subtokens w/ high enough counts.
    for i in xrange(num_iterations):
      tf.logging.info("\tGenerating subtokens: iteration %d" % i)
      # Generate new subtoken->id dictionary using the new subtoken list.
      subtoken_dict = _list_to_index_dict(subtoken_list)
  
      # Create dict mapping subtoken->count, with additional subtokens created
      # from substrings taken from the tokens.
      subtoken_counts = _count_and_gen_subtokens(
          token_counts, alphabet, subtoken_dict, max_subtoken_length)
  
      # Generate new list of subtokens sorted by subtoken count.
      subtoken_list, max_subtoken_length = _gen_new_subtoken_list(
          subtoken_counts, min_count, alphabet, reserved_tokens)
  
      tf.logging.info("\tVocab size: %d" % len(subtoken_list))
    return subtoken_list