def update(self, docs, golds, drop=<NUM_LIT:0.0>, sgd=None, losses=None, component_cfg=None):
if len(docs) != len(golds):<EOL><INDENT>raise IndexError(Errors.E009.format(n_docs=len(docs), n_golds=len(golds)))<EOL><DEDENT>if len(docs) == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if sgd is None:<EOL><INDENT>if self._optimizer is None:<EOL><INDENT>self._optimizer = create_default_optimizer(Model.ops)<EOL><DEDENT>sgd = self._optimizer<EOL><DEDENT>gold_objs = []<EOL>doc_objs = []<EOL>for doc, gold in zip(docs, golds):<EOL><INDENT>if isinstance(doc, basestring_):<EOL><INDENT>doc = self.make_doc(doc)<EOL><DEDENT>if not isinstance(gold, GoldParse):<EOL><INDENT>gold = GoldParse(doc, **gold)<EOL><DEDENT>doc_objs.append(doc)<EOL>gold_objs.append(gold)<EOL><DEDENT>golds = gold_objs<EOL>docs = doc_objs<EOL>grads = {}<EOL>def get_grads(W, dW, key=None):<EOL><INDENT>grads[key] = (W, dW)<EOL><DEDENT>get_grads.alpha = sgd.alpha<EOL>get_grads.b1 = sgd.b1<EOL>get_grads.b2 = sgd.b2<EOL>pipes = list(self.pipeline)<EOL>random.shuffle(pipes)<EOL>if component_cfg is None:<EOL><INDENT>component_cfg = {}<EOL><DEDENT>for name, proc in pipes:<EOL><INDENT>if not hasattr(proc, "<STR_LIT>"):<EOL><INDENT>continue<EOL><DEDENT>grads = {}<EOL>kwargs = component_cfg.get(name, {})<EOL>kwargs.setdefault("<STR_LIT>", drop)<EOL>proc.update(docs, golds, sgd=get_grads, losses=losses, **kwargs)<EOL>for key, (W, dW) in grads.items():<EOL><INDENT>sgd(W, dW, key=key)<EOL><DEDENT><DEDENT>
Update the models in the pipeline.

        docs (iterable): A batch of `Doc` objects.
        golds (iterable): A batch of `GoldParse` objects.
        drop (float): The droput rate.
        sgd (callable): An optimizer.
        RETURNS (dict): Results from the update.

        DOCS: https://spacy.io/api/language#update