code: def get_term_freqs(
      doc_term_matrix: sp.csr_matrix,
      *,
      type_: Literal["linear", "sqrt", "log"] = "linear",
  ) -> np.ndarray:
      """
      Compute frequencies for all terms in a document-term matrix, with optional
      sub-linear scaling.
  
      Args:
          doc_term_matrix: M x N sparse matrix, where M is the # of docs and
              N is the # of unique terms. Values must be the linear, un-scaled counts
              of term n per doc m.
          type_: Scaling applied to absolute term counts.
              If 'linear', term counts are left as-is, since the sums are already
              linear; if 'sqrt', tf => sqrt(tf); if 'log', tf => log(tf) + 1.
  
      Returns:
          Array of term frequencies, with length equal to the # of unique terms
          (i.e. # of columns) in ``doc_term_matrix``.
  
      Raises:
          ValueError: if ``doc_term_matrix`` doesn't have any non-zero entries, or
              if ``type_`` isn't one of {"linear", "sqrt", "log"}.
      """
      if doc_term_matrix.nnz == 0:
          raise ValueError(
              "`doc_term_matrix` must have at least 1 non-zero entry"
          )
      tfs = np.asarray(doc_term_matrix.sum(axis=0)).ravel()
      if type_ == "linear":
          return tfs  # tfs is already linear
      elif type_ == "sqrt":
          return np.sqrt(tfs)
      elif type_ == "log":
          return np.log(tfs) + 1.0
      else:
          raise ValueError(
              errors.value_invalid_msg(
                  "type_", type_, {"linear", "sqrt", "log"}
              )
          )
  
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 1 for calling a global function with example usage: get_term_freqs(doc_term_matrix) and returns: tfs, np, unknown