def _document_frequency(X):
if sp.isspmatrix_csr(X):<EOL><INDENT>return np.bincount(X.indices, minlength=X.shape[<NUM_LIT:1>])<EOL><DEDENT>return np.diff(sp.csc_matrix(X, copy=False).indptr)<EOL>
Count the number of non-zero values for each feature in sparse X.