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