class_docstr: Indexing for text tokens.
  
  
  Build indices for the unknown token, reserved tokens, and input counter keys. Indexed tokens can
  be used by token embeddings.
  
  
  Parameters
  ----------
  counter : collections.Counter or None, default None
      Counts text token frequencies in the text data. Its keys will be indexed according to
      frequency thresholds such as `most_freq_count` and `min_freq`. Keys of `counter`,
      `unknown_token`, and values of `reserved_tokens` must be of the same hashable type.
      Examples: str, int, and tuple.
  most_freq_count : None or int, default None
      The maximum possible number of the most frequent tokens in the keys of `counter` that can be
      indexed. Note that this argument does not count any token from `reserved_tokens`. Suppose
      that there are different keys of `counter` whose frequency are the same, if indexing all of
      them will exceed this argument value, such keys will be indexed one by one according to
      their __cmp__() order until the frequency threshold is met. If this argument is None or
      larger than its largest possible value restricted by `counter` and `reserved_tokens`, this
      argument has no effect.
  min_freq : int, default 1
      The minimum frequency required for a token in the keys of `counter` to be indexed.
  unknown_token : hashable object, default '&lt;unk&gt;'
      The representation for any unknown token. In other words, any unknown token will be indexed
      as the same representation. Keys of `counter`, `unknown_token`, and values of
      `reserved_tokens` must be of the same hashable type. Examples: str, int, and tuple.
  reserved_tokens : list of hashable objects or None, default None
      A list of reserved tokens that will always be indexed, such as special symbols representing
      padding, beginning of sentence, and end of sentence. It cannot contain `unknown_token`, or
      duplicate reserved tokens. Keys of `counter`, `unknown_token`, and values of
      `reserved_tokens` must be of the same hashable type. Examples: str, int, and tuple.
  
  
  Attributes
  ----------
  unknown_token : hashable object
      The representation for any unknown token. In other words, any unknown token will be indexed
      as the same representation.
  reserved_tokens : list of strs or None
      A list of reserved tokens that will always be indexed.
docstr: Indexes keys of `counter`.
  
  
  Indexes keys of `counter` according to frequency thresholds such as `most_freq_count` and
  `min_freq`.
docstr_tok: ["Indexes","keys","of","`","counter","`",".","Indexes","keys","of","`","counter","`","according","to","frequency","thresholds","such","as","`","most_freq_count","`","and","`","min_freq","`","."]
code: def _index_counter_keys(
      self,
      counter,
      unknown_token,
      reserved_tokens,
      most_freq_count,
      min_freq,
  ):
      """Indexes keys of `counter`.
  
  
      Indexes keys of `counter` according to frequency thresholds such as `most_freq_count` and
      `min_freq`.
      """
  
      assert isinstance(
          counter, collections.Counter
      ), "`counter` must be an instance of collections.Counter."
  
      unknown_and_reserved_tokens = (
          set(reserved_tokens) if reserved_tokens is not None else set()
      )
      unknown_and_reserved_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_reserved_tokens) + (
          len(counter) if most_freq_count is None else most_freq_count
      )
  
      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_reserved_tokens:
              self._idx_to_token.append(token)
              self._token_to_idx[token] = len(self._idx_to_token) - 1
  
file_path: mxnet/python/mxnet/contrib/text/vocab.py
imports: import collections
  from .None import _constants
label_desc: Use image node_id 3 for calling the Vocabulary obj's underlying member method code with example usage: obj._index_counter_keys(counter, unknown_token, reserved_tokens, most_freq_count, min_freq) without return types