code: def test_overfitting_IO(use_upper):
      # Simple test to try and quickly overfit the NER component
      nlp = English()
      ner = nlp.add_pipe(
          "ner", config={"model": {"use_upper": use_upper}}
      )
      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()
  
      for i in range(50):
          losses = {}
          nlp.update(train_examples, sgd=optimizer, losses=losses)
      assert losses["ner"] < 0.00001
  
      # test the trained model
      test_text = "I like London."
      doc = nlp(test_text)
      ents = doc.ents
      assert len(ents) == 1
      assert ents[0].text == "London"
      assert ents[0].label_ == "LOC"
  
      # 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)
          doc2 = nlp2(test_text)
          ents2 = doc2.ents
          assert len(ents2) == 1
          assert ents2[0].text == "London"
          assert ents2[0].label_ == "LOC"
          # Ensure that the predictions are still the same, even after adding a new label
          ner2 = nlp2.get_pipe("ner")
          assert ner2.model.attrs["has_upper"] == use_upper
          ner2.add_label("RANDOM_NEW_LABEL")
          doc3 = nlp2(test_text)
          ents3 = doc3.ents
          assert len(ents3) == 1
          assert ents3[0].text == "London"
          assert ents3[0].label_ == "LOC"
  
      # Make sure that running pipe twice, or comparing to call, always amounts to the same predictions
      texts = [
          "Just a sentence.",
          "Then one more sentence about London.",
          "Here is another one.",
          "I like London.",
      ]
      batch_deps_1 = [
          doc.to_array([ENT_IOB]) for doc in nlp.pipe(texts)
      ]
      batch_deps_2 = [
          doc.to_array([ENT_IOB]) for doc in nlp.pipe(texts)
      ]
      no_batch_deps = [
          doc.to_array([ENT_IOB])
          for doc in [nlp(text) for text in texts]
      ]
      assert_equal(batch_deps_1, batch_deps_2)
      assert_equal(batch_deps_1, no_batch_deps)
  
      # test that kb_id is preserved
      test_text = "I like London and London."
      doc = nlp.make_doc(test_text)
      doc.ents = [Span(doc, 2, 3, label="LOC", kb_id=1234)]
      ents = doc.ents
      assert len(ents) == 1
      assert ents[0].text == "London"
      assert ents[0].label_ == "LOC"
      assert ents[0].kb_id == 1234
      doc = nlp.get_pipe("ner")(doc)
      ents = doc.ents
      assert len(ents) == 2
      assert ents[0].text == "London"
      assert ents[0].label_ == "LOC"
      assert ents[0].kb_id == 1234
      # ent added by ner has kb_id == 0
      assert ents[1].text == "London"
      assert ents[1].label_ == "LOC"
      assert ents[1].kb_id == 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 31 for calling a global function with example usage: test_overfitting_IO(use_upper) without return types