code: def _index_counter_keys(self, counter, unknown_token, special_tokens, max_size,
                              min_freq):
          
  
          unknown_and_special_tokens = set(special_tokens) if special_tokens else set()
  
          if unknown_token:
              unknown_and_special_tokens.add(unknown_token)
  
          token_freqs = sorted(counter.items(), key=lambda x: x[0])
          token_freqs.sort(key=lambda x: x[1], reverse=True)
  
          token_cap = len(unknown_and_special_tokens) + (
              len(counter) if not max_size else max_size)
  
          for token, freq in token_freqs:
              if freq < min_freq or len(self._idx_to_token) == token_cap:
                  break
              if token not in unknown_and_special_tokens:
                  self._idx_to_token.append(token)
                  self._token_to_idx[token] = len(self._idx_to_token) - 1
docs: Indexes keys of `counter`.
  
  
          Indexes keys of `counter` according to frequency thresholds such as `max_size` and
          `min_freq`.