              for label, freq in labels.items():
                  if label not in actions[action]:
                      actions[action][label] = freq
          self.moves.initialize_actions(actions)
          cfg.setdefault('token_vector_width', 96)
          if self.model is True:
              self.model, cfg = self.Model(self.moves.n_moves, **cfg)
              if sgd is None:
                  sgd = self.create_optimizer()
              doc_sample = []
              gold_sample = []
              for example in islice(get_examples(), 1000):
                  parses = example.get_gold_parses(merge=False, vocab=self.vocab)
                  for doc, gold in parses:
                      doc_sample.append(doc)
                      gold_sample.append(gold)
              self.model.initialize(doc_sample, gold_sample)
              if pipeline is not None:
                  self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **cfg)
              link_vectors_to_models(self.vocab)
          else:
              if sgd is None:
                  sgd = self.create_optimizer()
              if self.model.upper.has_dim("nO") is None:
                  self.model.upper.set_dim("nO", self.moves.n_moves)
              self.model.initialize()
          self.cfg.update(cfg)
          return sgd
  
      def _get_doc(self, example):
          """ Use this method if the `example` can be both a Doc or an Example """
          if isinstance(example, Doc):
 
</s> remove                 if getattr(model, "tok2vec", None):
                    self.input_models.append(model.tok2vec)
        if self.model is True:
            self.model = self.Model(**self.cfg)
 </s> add                 if model.has_ref("tok2vec"):
                    self.input_models.append(model.get_ref("tok2vec")) </s> remove         if self.model is True:
            token_vector_width = util.env_opt("token_vector_width")
            self.model = self.Model(len(self.labels), tok2vec=tok2vec)
        link_vectors_to_models(self.vocab)
 </s> add  </s> remove     def Model(cls, *shape, **kwargs):
        """Initialize a model for the pipe."""
        raise NotImplementedError

    @classmethod
    def from_nlp(cls, nlp, **cfg):
        return cls(nlp.vocab, **cfg)
 </s> add     def from_nlp(cls, nlp, model, **cfg):
        return cls(nlp.vocab, model, **cfg) </s> remove         self.model.initialize()
 </s> add 
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
              for label, freq in labels.items():
                  if label not in actions[action]:
                      actions[action][label] = freq
          self.moves.initialize_actions(actions)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
        # make sure we resize so we have an appropriate upper layer
        self._resize()
        if sgd is None:
            sgd = self.create_optimizer()
        doc_sample = []
        gold_sample = []
        for example in islice(get_examples(), 1000):
            parses = example.get_gold_parses(merge=False, vocab=self.vocab)
            for doc, gold in parses:
                doc_sample.append(doc)
                gold_sample.append(gold)

        self.model.initialize(doc_sample, gold_sample)
        if pipeline is not None:
            self.init_multitask_objectives(get_examples, pipeline, sgd=sgd, **self.cfg)
        link_vectors_to_models(self.vocab)
          return sgd
  
      def _get_doc(self, example):
          """ Use this method if the `example` can be both a Doc or an Example """
          if isinstance(example, Doc):
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Default settings to configurations (#4995)

* fix grad_clip naming

* cleaning up pretrained_vectors out of cfg

* further refactoring Model init's

* move Model building out of pipes

* further refactor to require a model config when creating a pipe

* small fixes

* making cfg in nn_parser more consistent

* fixing nr_class for parser

* fixing nn_parser's nO

* fix printing of loss

* architectures in own file per type, consistent naming

* convenience methods default_tagger_config and default_tok2vec_config

* let create_pipe access default config if available for that component

* default_parser_config

* move defaults to separate folder

* allow reading nlp from package or dir with argument 'name'

* architecture spacy.VocabVectors.v1 to read static vectors from file

* cleanup

* default configs for nel, textcat, morphologizer, tensorizer

* fix imports

* fixing unit tests

* fixes and clean up

* fixing defaults, nO, fix unit tests

* restore parser IO

* fix IO

* 'fix' serialization test

* add *.cfg to manifest

* fix example configs with additional arguments

* replace Morpohologizer with Tagger

* add IO bit when testing overfitting of tagger (currently failing)

* fix IO - don't initialize when reading from disk

* expand overfitting tests to also check IO goes OK

* remove dropout from HashEmbed to fix Tagger performance

* add defaults for sentrec

* update thinc

* always pass a Model instance to a Pipe

* fix piped_added statement

* remove obsolete W029

* remove obsolete errors

* restore byte checking tests (work again)

* clean up test

* further test cleanup

* convert from config to Model in create_pipe

* bring back error when component is not initialized

* cleanup

* remove calls for nlp2.begin_training

* use thinc.api in imports

* allow setting charembed's nM and nC

* fix for hardcoded nM/nC + unit test

* formatting fixes

* trigger build 
spacy/syntax/nn_parser.pyx