  
  
  def load_model_from_init_py(init_file, **overrides):
      """Helper function to use in the `load()` method of a model package's
      __init__.py.
  
 
</s> remove         self.require_model()
 </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)
def load_model_from_config(nlp_config):
    if "name" in nlp_config:
        nlp = load_model(**nlp_config)
    elif "lang" in nlp_config:
        lang_class = get_lang_class(nlp_config["lang"])
        nlp = lang_class()
    else:
        raise ValueError(Errors.E993)
    if "pipeline" in nlp_config:
        for name, component_cfg in nlp_config["pipeline"].items():
            factory = component_cfg.pop("factory")
            component = nlp.create_pipe(factory, config=component_cfg)
            nlp.add_pipe(component, name=name)
    return nlp


  
  
def load_model_from_config(nlp_config):
    if "name" in nlp_config:
        nlp = load_model(**nlp_config)
    elif "lang" in nlp_config:
        lang_class = get_lang_class(nlp_config["lang"])
        nlp = lang_class()
    else:
        raise ValueError(Errors.E993)
    if "pipeline" in nlp_config:
        for name, component_cfg in nlp_config["pipeline"].items():
            factory = component_cfg.pop("factory")
            component = nlp.create_pipe(factory, config=component_cfg)
            nlp.add_pipe(component, name=name)
    return nlp


  def load_model_from_init_py(init_file, **overrides):
      """Helper function to use in the `load()` method of a model package's
      __init__.py.
  
keep add 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/util.py