code: def _sparse_document_frequency(X):
      """Count the number of non-zero values for each feature in sparse X."""
      if cupyx.scipy.sparse.isspmatrix_csr(X):
          return cp.bincount(X.indices, minlength=X.shape[1])
      else:
          return cp.diff(X.indptr)
  
imports: from cuml import Base
  from cuml.internals.array import CumlArray
  from cuml.common.sparsefuncs import csr_diag_mul
  from cuml.common.sparsefuncs import csr_row_normalize_l1, csr_row_normalize_l2
  import cuml.internals
  from cuml.common.exceptions import NotFittedError
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 1 for calling a global function with example usage: _sparse_document_frequency(X) and returns: cp, cp