code: def test_resize_same_results(name, textcat_config):
      # Ensure that the resized textcat classifiers still produce the same results for old labels
      fix_random_seed(0)
      nlp = English()
      pipe_config = {"model": textcat_config}
      textcat = nlp.add_pipe(name, config=pipe_config)
  
      train_examples = []
      for text, annotations in TRAIN_DATA_SINGLE_LABEL:
          train_examples.append(
              Example.from_dict(nlp.make_doc(text), annotations)
          )
      optimizer = nlp.initialize(get_examples=lambda: train_examples)
      assert textcat.model.maybe_get_dim("nO") in [2, None]
  
      for i in range(5):
          losses = {}
          nlp.update(train_examples, sgd=optimizer, losses=losses)
  
      # test the trained model before resizing
      test_text = "I am happy."
      doc = nlp(test_text)
      assert len(doc.cats) == 2
      pos_pred = doc.cats["POSITIVE"]
      neg_pred = doc.cats["NEGATIVE"]
  
      # test the trained model again after resizing
      textcat.add_label("NEUTRAL")
      doc = nlp(test_text)
      assert len(doc.cats) == 3
      assert doc.cats["POSITIVE"] == pos_pred
      assert doc.cats["NEGATIVE"] == neg_pred
      assert doc.cats["NEUTRAL"] <= 1
  
      for i in range(5):
          losses = {}
          nlp.update(train_examples, sgd=optimizer, losses=losses)
  
      # test the trained model again after training further with new label
      doc = nlp(test_text)
      assert len(doc.cats) == 3
      assert doc.cats["POSITIVE"] != pos_pred
      assert doc.cats["NEGATIVE"] != neg_pred
      for cat in doc.cats:
          assert doc.cats[cat] <= 1
  
imports: import random
  import numpy.random
  import pytest
  from numpy.testing import assert_almost_equal
  from thinc.api import Config, compounding, fix_random_seed, get_current_ops
  from wasabi import msg
  import spacy
  from spacy import util
  from spacy.cli.evaluate import print_prf_per_type, print_textcats_auc_per_cat
  from spacy.lang.en import English
  from spacy.language import Language
  from spacy.pipeline import TextCategorizer
  from spacy.pipeline.textcat import single_label_bow_config, single_label_cnn_config, single_label_default_config
  from spacy.pipeline.textcat_multilabel import multi_label_bow_config, multi_label_cnn_config, multi_label_default_config
  from spacy.pipeline.tok2vec import DEFAULT_TOK2VEC_MODEL
  from spacy.scorer import Scorer
  from spacy.tokens import Doc, DocBin
  from spacy.training import Example
  from spacy.training.initialize import init_nlp
  from ..util import make_tempdir
label_desc: Use image node_id 17 for calling a global function with example usage: test_resize_same_results(name, textcat_config) without return types