class_docstr: Convert a collection of text documents to a matrix of token counts
  This implementation produces a sparse representation of the counts using
  scipy.sparse.csr_matrix.
  
  Parameters
  ----------
  tokenizer: Tokenizer, optional, default=None
      Tokenizer for text splitting. If None, the BaseTokenizer will be used.
  
  vocab: Vocabulary, optional, default = None
      Vocabulary of tokens. It contains mapping between tokens to their
      integer ids and vice versa.
  
  max_doc_freq: float in range [0.0, 1.0] or int, default=1.0
      When building the vocabulary ignore terms that have a document
      frequency strictly higher than the given threshold (corpus-specific
      stop words).
      If float, the value represents a proportion of documents, int for absolute counts.
      If `vocab` is not None, this will be ignored.
  
  min_doc_freq: float in range [0.0, 1.0] or int, default=1
      When building the vocabulary ignore terms that have a document
      frequency strictly lower than the given threshold. This value is also
      called cut-off in the literature.
      If float, the value represents a proportion of documents, int absolute counts.
      If `vocab` is not None, this will be ignored.
  
  max_features : int or None, optional, default=None
      If not None, build a vocabulary that only consider the top
      `max_features` ordered by term frequency across the corpus.
      If `vocab` is not None, this will be ignored.
  
  binary : boolean, default=False
      If True, all non zero counts are set to 1.
  
  Reference
  ---------
  https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/text.py#L790
class_docstr_tok: ["Convert","a","collection","of","text","documents","to","a","matrix","of","token","counts","This","implementation","produces","a","sparse","representation","of","the","counts","using","scipy.sparse.csr_matrix",".","Parameters","--","--","--","--","--","tokenizer",":","Tokenizer",",","optional",",","default=None","Tokenizer","for","text","splitting",".","If","None",",","the","BaseTokenizer","will","be","used",".","vocab",":","Vocabulary",",","optional",",","default","=","None","Vocabulary","of","tokens",".","It","contains","mapping","between","tokens","to","their","integer","ids","and","vice","versa",".","max_doc_freq",":","float","in","range","[","0.0",",","1.0","]","or","int",",","default=1.0","When","building","the","vocabulary","ignore","terms","that","have","a","document","frequency","strictly","higher","than","the","given","threshold","(","corpus-specific","stop","words",")",".","If","float",",","the","value","represents","a","proportion","of","documents",",","int","for","absolute","counts",".","If","`","vocab","`","is","not","None",",","this","will","be","ignored",".","min_doc_freq",":","float","in","range","[","0.0",",","1.0","]","or","int",",","default=1","When","building","the","vocabulary","ignore","terms","that","have","a","document","frequency","strictly","lower","than","the","given","threshold",".","This","value","is","also","called","cut-off","in","the","literature",".","If","float",",","the","value","represents","a","proportion","of","documents",",","int","absolute","counts",".","If","`","vocab","`","is","not","None",",","this","will","be","ignored",".","max_features",":","int","or","None",",","optional",",","default=None","If","not","None",",","build","a","vocabulary","that","only","consider","the","top","`","max_features","`","ordered","by","term","frequency","across","the","corpus",".","If","`","vocab","`","is","not","None",",","this","will","be","ignored",".","binary",":","boolean",",","default=False","If","True",",","all","non","zero","counts","are","set","to","1",".","Reference","--","--","--","--","-","https",":","\/\/github.com\/scikit-learn\/scikit-learn\/blob\/master\/sklearn\/feature_extraction\/text.py","#","L790"]
docstr: Remove too common features.
  Prune features that are non zero in more samples than max_doc_count
  and modifying the vocabulary.
docstr_tok: ["Remove","too","common","features",".","Prune","features","that","are","non","zero","in","more","samples","than","max_doc_count","and","modifying","the","vocabulary","."]
code: def _limit_features(
      self, X: sp.csr_matrix, max_doc_count: int, min_doc_count: int
  ):
      """Remove too common features.
      Prune features that are non zero in more samples than max_doc_count
      and modifying the vocabulary.
      """
      if (
          max_doc_count >= X.shape[0]
          and min_doc_count <= 1
          and self.max_features is None
      ):
          return X
  
      # Calculate a mask based on document frequencies
      doc_freq = np.bincount(X.indices, minlength=X.shape[1])
      term_indices = np.arange(
          X.shape[1]
      )  # terms are already sorted based on frequency from Vocabulary
      mask = np.ones(len(doc_freq), dtype=bool)
      if max_doc_count < X.shape[0]:
          mask &= doc_freq <= max_doc_count
      if min_doc_count > 1:
          mask &= doc_freq >= min_doc_count
  
      if (
          self.max_features is not None
          and mask.sum() > self.max_features
      ):
          mask_indices = term_indices[mask][: self.max_features]
          new_mask = np.zeros(len(doc_freq), dtype=bool)
          new_mask[mask_indices] = True
          mask = new_mask
  
      for index in np.sort(np.where(np.logical_not(mask))[0])[::-1]:
          del self.vocab.idx2tok[index]
      self.vocab.build_tok2idx()  # rebuild the mapping
  
      kept_indices = np.where(mask)[0]
      if len(kept_indices) == 0:
          raise ValueError(
              "After pruning, no terms remain. Try a lower"
              " min_freq or a higher max_doc_freq."
          )
      return X[:, kept_indices]
  
imports: from typing import List, Dict, Callable, Union
  from collections import defaultdict, Counter, OrderedDict
  import string
  import pickle
  import re
  import numpy
  import scipy.sparse
  from .None import FeatureModality
  from .modality import fallback_feature
  from ..utils import normalize
label_desc: Use image node_id 2 for calling the CountVectorizer obj's underlying member method code with example usage: obj._limit_features(X, max_doc_count, min_doc_count) and returns: X, X