code: def test_transformer_pipeline_textcat():
      """Test that a pipeline with just a transformer+textcat runs and trains properly.
      This used to throw an error because of shape inference issues -
      cf https://github.com/explosion/spaCy/issues/6401"""
      orig_config = Config().from_str(cfg_string)
      nlp = util.load_model_from_config(
          orig_config, auto_fill=True, validate=True
      )
      assert nlp.pipe_names == ["transformer", "textcat"]
      train_examples = []
  
      for text, annotations in TRAIN_DATA:
          train_examples.append(
              Example.from_dict(nlp.make_doc(text), annotations)
          )
      optimizer = nlp.initialize(get_examples=lambda: train_examples)
  
      for i in range(2):
          losses = {}
          nlp.update(train_examples, sgd=optimizer, losses=losses)
  
      doc = nlp("We're interested at underwater basket weaving.")
      cats1 = doc.cats
  
      # ensure IO goes OK
      with make_tempdir() as d:
          file_path = d / "trained_nlp"
          nlp.to_disk(file_path)
          nlp2 = spacy.load(file_path)
          doc2 = nlp2("We're interested at underwater basket weaving.")
          cats2 = doc2.cats
          assert cats1 == cats2
  
imports: import spacy
  from spacy.training.example import Example
  from spacy.util import make_tempdir
  from spacy import util
  from thinc.api import Config
label_desc: Use image node_id 1 for calling a global function with example usage: test_transformer_pipeline_textcat() without return types