code: def test_count_vectorizer(give_vocabulary, distributed):
      m1 = sklearn.feature_extraction.text.CountVectorizer()
      b = db.from_sequence(JUNK_FOOD_DOCS, npartitions=2)
      r1 = m1.fit_transform(JUNK_FOOD_DOCS)
  
      if give_vocabulary:
          vocabulary = m1.vocabulary_
          m1 = sklearn.feature_extraction.text.CountVectorizer(
              vocabulary=vocabulary
          )
          r1 = m1.transform(JUNK_FOOD_DOCS)
      else:
          vocabulary = None
  
      m2 = dask_ml.feature_extraction.text.CountVectorizer(
          vocabulary=vocabulary
      )
  
      if distributed:
          client = Client()  # noqa
      else:
          client = dummy_context()
  
      if give_vocabulary:
          r2 = m2.transform(b)
      else:
          r2 = m2.fit_transform(b)
  
      with client:
          exclude = {"vocabulary_actor_", "stop_words_"}
          if give_vocabulary:
              # In scikit-learn, `.transform()` sets these.
              # This looks buggy.
              exclude |= {"vocabulary_", "fixed_vocabulary_"}
  
          assert_estimator_equal(m1, m2, exclude=exclude)
          assert isinstance(r2, da.Array)
          assert isinstance(r2._meta, scipy.sparse.csr_matrix)
          np.testing.assert_array_equal(
              r1.toarray(), r2.compute().toarray()
          )
  
          r3 = m2.transform(b)
          assert isinstance(r3, da.Array)
          assert isinstance(r3._meta, scipy.sparse.csr_matrix)
          np.testing.assert_array_equal(
              r1.toarray(), r3.compute().toarray()
          )
  
          if give_vocabulary:
              r4 = m2.fit_transform(b)
              assert isinstance(r4, da.Array)
              assert isinstance(r4._meta, scipy.sparse.csr_matrix)
              np.testing.assert_array_equal(
                  r1.toarray(), r4.compute().toarray()
              )
  
file_path: dask-ml/tests/feature_extraction/test_text.py
imports: import dask.array
  import dask.bag
  import dask.dataframe
  import numpy
  import pandas
  import pytest
  import scipy.sparse
  import sklearn.feature_extraction.text
  from distributed import Client
  import dask_ml.feature_extraction.text
  from dask_ml._compat import dummy_context
  from dask_ml.utils import assert_estimator_equal
label_desc: Use image node_id 6 for calling a global function with example usage: test_count_vectorizer(give_vocabulary, distributed) without return types