code: def test_beam_overfitting_IO(neg_key):
      # Simple test to try and quickly overfit the Beam NER component
      nlp = English()
      beam_width = 16
      beam_density = 0.0001
      config = {
          "beam_width": beam_width,
          "beam_density": beam_density,
          "incorrect_spans_key": neg_key,
      }
      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()
  
      # run overfitting
      for i in range(50):
          losses = {}
          nlp.update(train_examples, sgd=optimizer, losses=losses)
      assert losses["beam_ner"] < 0.0001
  
      # test the scores from the beam
      test_text = "I like London"
      docs = [nlp.make_doc(test_text)]
      beams = ner.predict(docs)
      entity_scores = ner.scored_ents(beams)[0]
      assert entity_scores[(2, 3, "LOC")] == 1.0
      assert entity_scores[(2, 3, "PERSON")] == 0.0
      assert len(nlp(test_text).ents) == 1
  
      # Also test the results are still the same after IO
      with make_tempdir() as tmp_dir:
          nlp.to_disk(tmp_dir)
          nlp2 = util.load_model_from_path(tmp_dir)
          docs2 = [nlp2.make_doc(test_text)]
          ner2 = nlp2.get_pipe("beam_ner")
          beams2 = ner2.predict(docs2)
          entity_scores2 = ner2.scored_ents(beams2)[0]
          assert entity_scores2[(2, 3, "LOC")] == 1.0
          assert entity_scores2[(2, 3, "PERSON")] == 0.0
  
      # Try to unlearn the entity by using negative annotations
      neg_doc = nlp.make_doc(test_text)
      neg_ex = Example(neg_doc, neg_doc)
      neg_ex.reference.spans[neg_key] = [Span(neg_doc, 2, 3, "LOC")]
      neg_train_examples = [neg_ex]
  
      for i in range(20):
          losses = {}
          nlp.update(neg_train_examples, sgd=optimizer, losses=losses)
  
      # test the "untrained" model
      assert len(nlp(test_text).ents) == 0
  
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 33 for calling a global function with example usage: test_beam_overfitting_IO(neg_key) without return types