          loss = loss / len(cats)
          return loss, d_scores
  
      def __call__(self, doc):
          entities, kb_ids = self.predict([doc])
          self.set_annotations([doc], entities, kb_ids)
          return doc
  
      def pipe(self, stream, batch_size=128, n_threads=-1):
          for docs in util.minibatch(stream, size=batch_size):
              docs = list(docs)
 
</s> remove             entities, kb_ids = self.predict(docs)
            self.set_annotations(docs, entities, kb_ids)
 </s> add             kb_ids = self.predict(docs)
            self.set_annotations(docs, kb_ids) </s> remove     def set_annotations(self, docs, entities, kb_ids=None):
        for entity, kb_id in zip(entities, kb_ids):
            for token in entity:
                token.ent_kb_id_ = kb_id
 </s> add         return final_kb_ids

    def set_annotations(self, docs, kb_ids, tensors=None):
        i=0
        for doc in docs:
            for ent in doc.ents:
                kb_id = kb_ids[i]
                i += 1
                for token in ent:
                    token.ent_kb_id_ = kb_id </s> remove             for entity, value in gold.links.items():
                cats.append([value])
 </s> add             for entity, kb_dict in gold.links.items():
                for kb_id, value in kb_dict.items():
                    cats.append([value]) </s> remove             return final_entities, final_kb_ids
 </s> add             return final_kb_ids </s> remove         return final_entities, final_kb_ids
 </s> add         assert len(final_kb_ids) == entity_count
        kb_ids = self.predict([doc])
        self.set_annotations([doc], kb_ids)
          loss = loss / len(cats)
          return loss, d_scores
  
      def __call__(self, doc):
        kb_ids = self.predict([doc])
        self.set_annotations([doc], kb_ids)
        kb_ids = self.predict([doc])
        self.set_annotations([doc], kb_ids)
          return doc
  
      def pipe(self, stream, batch_size=128, n_threads=-1):
          for docs in util.minibatch(stream, size=batch_size):
              docs = list(docs)
keep keep keep keep replace replace keep keep keep keep keep
 have gold.links correspond exactly to doc.ents 
spacy/pipeline/pipes.pyx