code: def get_inverse_doc_freqs(
      doc_term_matrix: sp.csr_matrix,
      *,
      type_: Literal["standard", "smooth", "bm25"] = "smooth",
  ) -> np.ndarray:
      """
      Compute inverse document frequencies for all terms in a document-term matrix,
      using one of several IDF formulations.
  
      Args:
          doc_term_matrix: M x N sparse matrix, where M is the # of docs and
              N is the # of unique terms. The particular weighting of matrix values
              doesn't matter.
          type_: Type of IDF formulation to use.
              If 'standard', idfs => log(n_docs / dfs) + 1.0;
              if 'smooth', idfs => log(n_docs + 1 / dfs + 1) + 1.0, i.e. 1 is added
              to all document frequencies, equivalent to adding a single document
              to the corpus containing every unique term;
              if 'bm25', idfs => log((n_docs - dfs + 0.5) / (dfs + 0.5)), which is
              a form commonly used in BM25 ranking that allows for extremely common
              terms to have negative idf weights.
  
      Returns:
          Array of inverse document frequencies, with length equal to
          the # of unique terms (i.e. # of columns) in ``doc_term_matrix``.
  
      Raises:
          ValueError: if ``type_`` isn't one of {"standard", "smooth", "bm25"}.
      """
      dfs = get_doc_freqs(doc_term_matrix)
      n_docs, _ = doc_term_matrix.shape
      if type_ == "standard":
          return np.log(n_docs / dfs) + 1.0
      elif type_ == "smooth":
          n_docs += 1
          dfs += 1
          return np.log(n_docs / dfs) + 1.0
      elif type_ == "bm25":
          return np.log((n_docs - dfs + 0.5) / (dfs + 0.5))
      else:
          raise ValueError(
              errors.value_invalid_msg(
                  "type_", type_, {"standard", "smooth", "bm25"}
              )
          )
  
file_path: textacy/src/textacy/representations/matrix_utils.py
imports: from __future__ import annotations
  from typing import Literal, Optional
  import numpy
  import scipy.sparse
  from ..None import errors
label_desc: Use image node_id 3 for calling a global function with example usage: get_inverse_doc_freqs(doc_term_matrix) and returns: unknown, unknown, np