class_docstr: Pipeline component for named entity linking.
  
  DOCS: https://spacy.io/api/entitylinker
class_docstr_tok: ["Pipeline","component","for","named","entity","linking",".","DOCS",":","https",":","\/\/spacy.io\/api\/entitylinker"]
docstr: Initialize the pipe for training, using a representative set
  of data examples.
  
  get_examples (Callable[[], Iterable[Example]]): Function that
      returns a representative sample of gold-standard Example objects.
  nlp (Language): The current nlp object the component is part of.
  kb_loader (Callable[[Vocab], KnowledgeBase]): A function that creates a KnowledgeBase from a Vocab
      instance. Note that providing this argument will overwrite all data accumulated in the current KB.
      Use this only when loading a KB as-such from file.
  
  DOCS: https://spacy.io/api/entitylinker#initialize
docstr_tok: ["Initialize","the","pipe","for","training",",","using","a","representative","set","of","data","examples",".","get_examples","(","Callable","[","[","]",",","Iterable","[","Example","]","]",")",":","Function","that","returns","a","representative","sample","of","gold-standard","Example","objects",".","nlp","(","Language",")",":","The","current","nlp","object","the","component","is","part","of",".","kb_loader","(","Callable","[","[","Vocab","]",",","KnowledgeBase","]",")",":","A","function","that","creates","a","KnowledgeBase","from","a","Vocab","instance",".","Note","that","providing","this","argument","will","overwrite","all","data","accumulated","in","the","current","KB",".","Use","this","only","when","loading","a","KB","as-such","from","file",".","DOCS",":","https",":","\/\/spacy.io\/api\/entitylinker","#","initialize"]
code: def initialize(
      self,
      get_examples: Callable[[], Iterable[Example]],
      *,
      nlp: Optional[Language] = None,
      kb_loader: Optional[Callable[[Vocab], KnowledgeBase]] = None,
  ):
      """Initialize the pipe for training, using a representative set
      of data examples.
  
      get_examples (Callable[[], Iterable[Example]]): Function that
          returns a representative sample of gold-standard Example objects.
      nlp (Language): The current nlp object the component is part of.
      kb_loader (Callable[[Vocab], KnowledgeBase]): A function that creates a KnowledgeBase from a Vocab
          instance. Note that providing this argument will overwrite all data accumulated in the current KB.
          Use this only when loading a KB as-such from file.
  
      DOCS: https://spacy.io/api/entitylinker#initialize
      """
      validate_get_examples(get_examples, "EntityLinker.initialize")
      if kb_loader is not None:
          self.set_kb(kb_loader)
      self.validate_kb()
      nO = self.kb.entity_vector_length
      doc_sample = []
      vector_sample = []
      for eg in islice(get_examples(), 10):
          doc = eg.x
          if self.use_gold_ents:
              ents, _ = eg.get_aligned_ents_and_ner()
              doc.ents = ents
          doc_sample.append(doc)
          vector_sample.append(self.model.ops.alloc1f(nO))
      assert len(doc_sample) > 0, Errors.E923.format(name=self.name)
      assert len(vector_sample) > 0, Errors.E923.format(name=self.name)
  
      # XXX In order for size estimation to work, there has to be at least
      # one entity. It's not used for training so it doesn't have to be real,
      # so we add a fake one if none are present.
      # We can't use Doc.has_annotation here because it can be True for docs
      # that have been through an NER component but got no entities.
      has_annotations = any([doc.ents for doc in doc_sample])
      if not has_annotations:
          doc = doc_sample[0]
          ent = doc[0:1]
          ent.label_ = "XXX"
          doc.ents = (ent,)
  
      self.model.initialize(
          X=doc_sample,
          Y=self.model.ops.asarray(vector_sample, dtype="float32"),
      )
  
      if not has_annotations:
          # Clean up dummy annotation
          doc.ents = []
  
imports: import random
  from itertools import islice
  from pathlib import Path
  from typing import Any, Callable, Dict, Iterable, List, Optional, Union
  import srsly
  from thinc.api import Config, CosineDistance, Model, Optimizer, set_dropout_rate
  from thinc.types import Floats2d
  from ..None import util
  from ..errors import Errors
  from ..kb import Candidate, KnowledgeBase
  from ..language import Language
  from ..ml import empty_kb
  from ..scorer import Scorer
  from ..tokens import Doc, Span
  from ..training import Example, validate_examples, validate_get_examples
  from ..util import SimpleFrozenList, registry
  from ..vocab import Vocab
  from .legacy.entity_linker import EntityLinker_v1
  from .pipe import deserialize_config
  from .trainable_pipe import TrainablePipe
label_desc: Use image node_id 4 for calling the EntityLinker obj's underlying member method code with example usage: obj.initialize(get_examples) without return types