code: def create_csr_matrix_from_count_df(
      count_df, empty_doc_ids, n_doc, n_features, dtype=np.float32
  ):
      """
      Create a sparse matrix from the count of tokens by document
  
      Parameters
      ----------
          count_df = cudf.DataFrame({'count':..., 'doc_id':.., 'token':.. })
                      sorted by doc_id and token
          empty_doc_ids = cupy array containing doc_ids with no tokens
          n_doc: Total number of documents
          n_features: Number of features
          dtype: Output dtype
      """
      data = count_df["count"].values
      indices = count_df["token"].values
  
      doc_token_counts = count_df["doc_id"].value_counts().reset_index()
      del count_df
      doc_token_counts = doc_token_counts.rename(
          {"doc_id": "token_counts", "index": "doc_id"}, axis=1
      ).sort_values(by="doc_id")
  
      token_counts = _insert_zeros(
          doc_token_counts["token_counts"], empty_doc_ids
      )
      indptr = token_counts.cumsum()
      indptr = cp.pad(indptr, (1, 0), "constant")
  
      return cupyx.scipy.sparse.csr_matrix(
          arg1=(data, indices, indptr),
          dtype=dtype,
          shape=(n_doc, n_features),
      )
  
file_path: cuml/python/cuml/common/sparsefuncs.py
imports: import math
  import cuml
  from cuml.internals.input_utils import input_to_cuml_array, input_to_cupy_array
  from cuml.internals.memory_utils import with_cupy_rmm
  from cuml.internals.import_utils import has_scipy
  from cuml.common.kernel_utils import cuda_kernel_factory
  from cuml.internals.safe_imports import cpu_only_import
  from cuml.internals.safe_imports import gpu_only_import
  from cuml.internals.safe_imports import gpu_only_import_from
label_desc: Use image node_id 6 for calling a global function with example usage: create_csr_matrix_from_count_df(count_df, empty_doc_ids, n_doc, n_features, dtype) and returns: cupyx