code: def _get_term_indices_to_compact_from_term_freqs(
      self, term_freqs, term_doc_matrix, non_text
  ):
      idx = IndexStore()
      tdf_vals = term_freqs.values
      valid_terms_mask = tdf_vals.sum(axis=1) >= self.minimum_term_count
      tdf_vals = term_freqs[valid_terms_mask].values
      terms = np.array(term_freqs.index)[valid_terms_mask]
  
      lengths = []
      fact = CSRMatrixFactory()
      for i, t in enumerate(terms):
          for tok in t.split():
              fact[i, idx.getidx(tok)] = 1
          lengths.append(len(t.split()))
      lengths = np.array(lengths)
      mat = fact.get_csr_matrix()
  
      coocs = lengths - (mat * mat.T)
      pairs = np.argwhere(coocs == 0).T
      pairs = self._limit_to_non_identical_terms(pairs)
      pairs = self._limit_to_pairs_of_bigrams_and_a_constituent_unigram(
          pairs, terms
      )
      pairs = self._limit_to_redundant_unigrams(pairs, tdf_vals)
      idx_store = term_doc_matrix._get_relevant_idx_store(non_text)
      redundant_terms = idx_store.getidxstrictbatch(
          terms[np.unique(pairs[:, 1])]
      )
      infrequent_terms = np.argwhere(~valid_terms_mask).T[0]
      terms_to_remove = np.concatenate(
          [redundant_terms, infrequent_terms]
      )
      return terms_to_remove
  
file_path: scattertext/scattertext/termcompaction/CompactTerms.py
imports: import numpy
  from scattertext.CSRMatrixTools import CSRMatrixFactory
  from scattertext.indexstore import IndexStore
  from scattertext.termranking import AbsoluteFrequencyRanker
label_desc: Use image node_id 4 for calling the CompactTerms obj's underlying member method code with example usage: obj._get_term_indices_to_compact_from_term_freqs(term_freqs, term_doc_matrix, non_text) and returns: terms_to_remove