original_docstring: 
      Traverse all tokens from a given text and extract vocabulary
      :param Dict[str, int] term_frequencies: frequencies' dictionary of tokens.
      :param int min_term_frequency: The minimum frequency for a term to be saved in vocabulary
      :param int max_vocab_size: The maximum number of terms to keep in vocab. The least frequent will be truncated.
      :param Optional[Dict[str, int]] reserved_tokens: A list of reserved tokens with their id.
      If None is provided then the default <OOV> and <PAD> will be used.
      :rtype: Dict[str, int]
      
docstring: Traverse all tokens from a given text and extract vocabulary
  :param Dict[str, int] term_frequencies: frequencies' dictionary of tokens.
  :param int min_term_frequency: The minimum frequency for a term to be saved in vocabulary
  :param int max_vocab_size: The maximum number of terms to keep in vocab. The least frequent will be truncated.
  :param Optional[Dict[str, int]] reserved_tokens: A list of reserved tokens with their id.
  If None is provided then the default  and  will be used.
  :rtype: Dict[str, int]
docstring_tokens: Traverse all tokens from a given text and extract vocabulary : param Dict [ str int ] term_frequencies : frequencies ' dictionary of tokens . : param int min_term_frequency : The minimum frequency for a term to be saved in vocabulary : param int max_vocab_size : The maximum number of terms to keep in vocab . The least frequent will be truncated . : param Optional [ Dict [ str int ]] reserved_tokens : A list of reserved tokens with their id . If None is provided then the default and will be used . : rtype : Dict [ str int ]
code: def extract_vocabulary(term_frequencies, min_term_frequency, max_vocab_size=None, reserved_tokens=None):
      """
      Traverse all tokens from a given text and extract vocabulary
      :param Dict[str, int] term_frequencies: frequencies' dictionary of tokens.
      :param int min_term_frequency: The minimum frequency for a term to be saved in vocabulary
      :param int max_vocab_size: The maximum number of terms to keep in vocab. The least frequent will be truncated.
      :param Optional[Dict[str, int]] reserved_tokens: A list of reserved tokens with their id.
      If None is provided then the default <OOV> and <PAD> will be used.
      :rtype: Dict[str, int]
      """
  
      if reserved_tokens is None:
          reserved_tokens = {
              '<PAD>': 0,
              '<OOV>': 1,
          }
      # Sort terms by frequency (ascending) and filter out those with small values
      terms = [
          term
          for term, frequency in sorted(term_frequencies.items(), key=lambda tup: tup[1], reverse=True)
          if frequency >= min_term_frequency
      ]
  
      # Truncate to maximum vocab size
      terms = terms[:max_vocab_size]
  
      # Word to Id
      word_to_id = {
          term: term_id
          for term, term_id in zip(terms, count(start=max(reserved_tokens.values()) + 1))
      }
  
      # Add reserved tokens in the index
      if word_to_id:
          word_to_id.update(reserved_tokens)
  
      return word_to_id
code_tokens: def extract_vocabulary ( term_frequencies , min_term_frequency , max_vocab_size = None , reserved_tokens = None ) : if reserved_tokens is None : reserved_tokens = { '<PAD>' : 0 , '<OOV>' : 1 , } terms = [ term for term , frequency in sorted ( term_frequencies . items ( ) , key = lambda tup : tup [ 1 ] , reverse = True ) if frequency >= min_term_frequency ] terms = terms [ : max_vocab_size ] word_to_id = { term : term_id for term , term_id in zip ( terms , count ( start = max ( reserved_tokens . values ( ) ) + 1 ) ) } if word_to_id : word_to_id . update ( reserved_tokens ) return word_to_id
short_docstring: Traverse all tokens from a given text and extract vocabulary
  :param Dict[str, int] term_frequencies: frequencies' dictionary of tokens.
short_docstring_tokens: Traverse all tokens from a given text and extract vocabulary : param Dict [ str int ] term_frequencies : frequencies ' dictionary of tokens .
comment: """
      Traverse all tokens from a given text and extract vocabulary
      :param Dict[str, int] term_frequencies: frequencies' dictionary of tokens.
      :param int min_term_frequency: The minimum frequency for a term to be saved in vocabulary
      :param int max_vocab_size: The maximum number of terms to keep in vocab. The least frequent will be truncated.
      :param Optional[Dict[str, int]] reserved_tokens: A list of reserved tokens with their id.
      If None is provided then the default <OOV> and <PAD> will be used.
      :rtype: Dict[str, int]
      """$SEP$# Sort terms by frequency (ascending) and filter out those with small values$SEP$# Truncate to maximum vocab size$SEP$# Word to Id$SEP$# Add reserved tokens in the index