docstr: Parameters
  ----------
  term_doc_matrix : TermDocMatrix
      Term document matrix object to compact
  Returns
  -------
  TermDocMatrix
docstr_tok: ["Parameters","--","--","--","--","--","term_doc_matrix",":","TermDocMatrix","Term","document","matrix","object","to","compact","Returns","--","--","--","-","TermDocMatrix"]
code: def compact(self, term_doc_matrix):
      """
      Parameters
      ----------
      term_doc_matrix : TermDocMatrix
          Term document matrix object to compact
      Returns
      -------
      TermDocMatrix
  
  
      """
      rank_df = self.scorer.get_rank_df(term_doc_matrix)
      return self._prune_higher_ranked_terms(
          term_doc_matrix, rank_df, self.rank
      )
  
imports: from typing import Optional, Tuple
  import pandas
  import numpy
  from scattertext.termscoring.CorpusBasedTermScorer import CorpusBasedTermScorer
  from scipy.stats import rankdata
  from scattertext.termranking.AbsoluteFrequencyRanker import AbsoluteFrequencyRanker
  from scattertext.termscoring.ScaledFScore import ScaledFScorePresetsNeg1To1
label_desc: Use image node_id 2 for calling the AssociationCompactorByRank obj's underlying member method code with example usage: obj.compact(term_doc_matrix) and returns: self