code: def learn(
      word_counts,
      vocab_size: int,
      reserved_tokens: List[str],
      upper_thresh: Optional[int] = int(1e7),
      lower_thresh: Optional[int] = 10,
      num_iterations: int = 4,
      max_input_tokens: Optional[int] = int(5e6),
      max_token_length: int = 50,
      max_unique_chars: int = 1000,
      slack_ratio: float = 0.05,
      include_joiner_token: bool = True,
      joiner: str = "##",
  ) -> List[str]:
      """Takes in wordcounts and returns wordpiece vocabulary.
  
      Args:
        word_counts: (word, count) pairs as a dictionary, or list of tuples.
        vocab_size: The target vocabulary size. This is the maximum size.
        reserved_tokens: A list of tokens that must be included in the vocabulary.
        upper_thresh: Initial upper bound on the token frequency threshold.
        lower_thresh: Initial lower bound on the token frequency threchold.
        num_iterations: Number of iterations to run.
        max_input_tokens: The maximum number of words in the initial vocabulary. The
          words with the lowest counts are discarded. Use `None` or `-1` for "no
          maximum".
        max_token_length: The maximum token length. Counts for longer words are
          discarded.
        max_unique_chars: The maximum alphabet size. This prevents rare characters
          from inflating the vocabulary. Counts for words containing characters
          ouside of the selected alphabet are discarded.
        slack_ratio: The maximum deviation acceptable from `vocab_size` for an
          acceptable vocabulary. The acceptable range of vocabulary sizes is from
          `vocab_size*(1-slack_ratio)` to `vocab_size`.
        include_joiner_token: If true, include the `joiner` token in the output
          vocabulary.
        joiner: The prefix to include on suffix tokens in the output vocabulary.
          Usually "##". For example 'places' could be tokenized as `['place',
          '##s']`.
  
      Returns:
        string, final vocabulary with each word separated by newline
      """
      if isinstance(word_counts, dict):
          word_counts = word_counts.items()
  
      params = Params(
          upper_thresh,
          lower_thresh,
          num_iterations,
          max_input_tokens,
          max_token_length,
          max_unique_chars,
          vocab_size,
          slack_ratio,
          include_joiner_token,
          joiner,
          reserved_tokens,
      )
  
      upper_search, lower_search = get_search_threshs(
          word_counts, params.upper_thresh, params.lower_thresh
      )
      all_counts = get_input_words(
          word_counts, params.reserved_tokens, params.max_token_length
      )
      allowed_chars = get_allowed_chars(
          all_counts, params.max_unique_chars
      )
  
      filtered_counts = filter_input_words(
          all_counts, allowed_chars, params.max_input_tokens
      )
  
      vocab = learn_binary_search(
          filtered_counts, lower_search, upper_search, params
      )
  
      return vocab
  
file_path: text/tensorflow_text/tools/wordpiece_vocab/wordpiece_tokenizer_learner_lib.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import List, Optional
  import numpy
label_desc: Use image node_id 12 for calling a global function with example usage: learn(word_counts, vocab_size, reserved_tokens, upper_thresh, lower_thresh, num_iterations, max_input_tokens, max_token_length, max_unique_chars, slack_ratio, include_joiner_token, joiner) and returns: vocab