  # fmt: on
  def test_tok2vec_configs(tok2vec_config):
      docs = get_batch(3)
      tok2vec = build_Tok2Vec_model(**tok2vec_config)
      tok2vec.initialize()
      vectors, backprop = tok2vec.begin_update(docs)
      assert len(vectors) == len(docs)
      assert vectors[0].shape == (len(docs[0]), tok2vec_config["width"])
      backprop(vectors)
 
</s> remove         return dY
 </s> add         return [] </s> remove 
def get_batch(batch_size):
    vocab = Vocab()
    docs = []
    start = 0
    for size in range(1, batch_size + 1):
        # Make the words numbers, so that they're distinct
        # across the batch, and easy to track.
        numbers = [str(i) for i in range(start, start + size)]
        docs.append(Doc(vocab, words=numbers))
        start += size
    return docs
 </s> add from .util import get_batch </s> remove             # TODO: experiment with init_w=zero_init
 </s> add  </s> remove         # TODO: charembed does not play nicely with dim inference yet
        # docs = [Doc(Vocab(), words=["hello"])]
        # self.model.initialize(X=docs)
        self.model.initialize()
 </s> add         docs = [Doc(Vocab(), words=["hello"])]
        self.model.initialize(X=docs)
    tok2vec.initialize(docs)
  # fmt: on
  def test_tok2vec_configs(tok2vec_config):
      docs = get_batch(3)
      tok2vec = build_Tok2Vec_model(**tok2vec_config)
    tok2vec.initialize(docs)
      vectors, backprop = tok2vec.begin_update(docs)
      assert len(vectors) == len(docs)
      assert vectors[0].shape == (len(docs[0]), tok2vec_config["width"])
      backprop(vectors)
keep keep keep keep replace keep keep keep keep
 Train textcat with config (#5143)

* bring back default build_text_classifier method

* remove _set_dims_ hack in favor of proper dim inference

* add tok2vec initialize to unit test

* small fixes

* add unit test for various textcat config settings

* logistic output layer does not have nO

* fix window_size setting

* proper fix

* fix W initialization

* Update textcat training example

* Use ml_datasets
* Convert training data to `Example` format
* Use `n_texts` to set proportionate dev size

* fix _init renaming on latest thinc

* avoid setting a non-existing dim

* update to thinc==8.0.0a2

* add BOW and CNN defaults for easy testing

* various experiments with train_textcat script, fix softmax activation in textcat bow

* allow textcat train script to work on other datasets as well

* have dataset as a parameter

* train textcat from config, with example config

* add config for training textcat

* formatting

* fix exclusive_classes

* fixing BOW for GPU

* bump thinc to 8.0.0a3 (not published yet so CI will fail)

* add in link_vectors_to_models which got deleted

Co-authored-by: Adriane Boyd <adrianeboyd@gmail.com> 
spacy/tests/test_tok2vec.py