code: def test_beam_ner_scores():
      # Test that we can get confidence values out of the beam_ner pipe
      beam_width = 16
      beam_density = 0.0001
      nlp = English()
      config = {
          "beam_width": beam_width,
          "beam_density": beam_density,
      }
      ner = nlp.add_pipe("beam_ner", config=config)
      train_examples = []
      for text, annotations in TRAIN_DATA:
          train_examples.append(
              Example.from_dict(nlp.make_doc(text), annotations)
          )
          for ent in annotations.get("entities"):
              ner.add_label(ent[2])
      optimizer = nlp.initialize()
  
      # update once
      losses = {}
      nlp.update(train_examples, sgd=optimizer, losses=losses)
  
      # test the scores from the beam
      test_text = "I like London."
      doc = nlp.make_doc(test_text)
      docs = [doc]
      beams = ner.predict(docs)
      entity_scores = ner.scored_ents(beams)[0]
  
      for j in range(len(doc)):
          for label in ner.labels:
              score = entity_scores[(j, j + 1, label)]
              eps = 0.00001
              assert 0 - eps <= score <= 1 + eps
  
imports: import logging
  import random
  import pytest
  from numpy.testing import assert_equal
  from spacy import registry, util
  from spacy.attrs import ENT_IOB
  from spacy.lang.en import English
  from spacy.lang.it import Italian
  from spacy.language import Language
  from spacy.lookups import Lookups
  from spacy.pipeline import EntityRecognizer
  from spacy.pipeline._parser_internals.ner import BiluoPushDown
  from spacy.pipeline.ner import DEFAULT_NER_MODEL
  from spacy.tokens import Doc, Span
  from spacy.training import Example, iob_to_biluo, split_bilu_label
  from spacy.vocab import Vocab
  from ..util import make_tempdir
label_desc: Use image node_id 32 for calling a global function with example usage: test_beam_ner_scores() without return types