code: def build_nel_encoder(
      tok2vec: Model, nO: Optional[int] = None
  ) -> Model[List[Doc], Floats2d]:
      with Model.define_operators({">>": chain, "&": tuplify}):
          token_width = tok2vec.maybe_get_dim("nO")
          output_layer = Linear(nO=nO, nI=token_width)
          model = (
              ((tok2vec >> list2ragged()) & build_span_maker())
              >> extract_spans()
              >> reduce_mean()
              >> residual(Maxout(nO=token_width, nI=token_width, nP=2, dropout=0.0))  # type: ignore
              >> output_layer
          )
          model.set_ref("output_layer", output_layer)
          model.set_ref("tok2vec", tok2vec)
      # flag to show this isn't legacy
      model.attrs["include_span_maker"] = True
      return model
  
file_path: spaCy/spacy/ml/models/entity_linker.py
imports: from pathlib import Path
  from typing import Callable, Iterable, List, Optional, Tuple
  from thinc.api import Linear, Maxout, Model, Ragged, chain, list2ragged, reduce_mean, residual, tuplify
  from thinc.types import Floats2d
  from ...errors import Errors
  from ...kb import Candidate, InMemoryLookupKB, KnowledgeBase, get_candidates, get_candidates_batch
  from ...tokens import Doc, Span
  from ...util import registry
  from ...vocab import Vocab
  from ..extract_spans import extract_spans
label_desc: Use image node_id 1 for calling a global function with example usage: build_nel_encoder(tok2vec, nO) and returns: model