code: def test_transformer_pipeline_tagger_senter_listener():
      """Test that a pipeline with just a transformer+tagger+senter runs and
      trains properly"""
      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", "tagger", "senter"]
      tagger = nlp.get_pipe("tagger")
      transformer = nlp.get_pipe("transformer")
      tagger_trf = tagger.model.get_ref("tok2vec").layers[0]
      assert isinstance(transformer, Transformer)
      assert isinstance(tagger_trf, TransformerListener)
      train_examples = []
      for t in TRAIN_DATA:
          train_examples.append(
              Example.from_dict(nlp.make_doc(t[0]), t[1])
          )
          for tag in t[1]["tags"]:
              tagger.add_label(tag)
  
      # Check that the Transformer component finds it listeners
      optimizer = nlp.initialize(lambda: train_examples)
      assert tagger_trf in transformer.listeners
  
      for i in range(2):
          losses = {}
          nlp.update(train_examples, sgd=optimizer, losses=losses)
  
      text = "We're interested at underwater basket weaving."
      doc = nlp(text)
      doc_tensor = tagger_trf.predict([doc])
      _assert_equal_tensors(
          doc._.trf_data.tensors, doc_tensor[0].tensors
      )
  
      # ensure IO goes OK
      with make_tempdir() as d:
          file_path = d / "trained_nlp"
          nlp.to_disk(file_path)
          nlp2 = util.load_model_from_path(file_path)
          doc2 = nlp2(text)
          tagger2 = nlp2.get_pipe("tagger")
          tagger_trf2 = tagger2.model.get_ref("tok2vec").layers[0]
          doc_tensor2 = tagger_trf2.predict([doc2])
          _assert_equal_tensors(
              doc_tensor2[0].tensors, doc_tensor[0].tensors
          )
  
          # make sure that this can be saved to directory once more
          file_path_2 = d / "trained_nlp_2"
          nlp2.to_disk(file_path_2)
  
      # ensure to_bytes / from_bytes works
      nlp_bytes = nlp.to_bytes()
      nlp3 = util.load_model_from_config(
          orig_config, auto_fill=True, validate=True
      )
      nlp3.from_bytes(nlp_bytes)
      doc3 = nlp3(text)
      tagger3 = nlp3.get_pipe("tagger")
      tagger_trf3 = tagger3.model.get_ref("tok2vec").layers[0]
      doc_tensor3 = tagger_trf3.predict([doc3])
      _assert_equal_tensors(
          doc_tensor3[0].tensors, doc_tensor[0].tensors
      )
  
imports: import pytest
  from packaging.version import Version
  import torch
  import spacy
  from spacy.language import Language
  from spacy.training.example import Example
  from spacy.util import make_tempdir
  from spacy.vocab import Vocab
  from spacy.tokens import Doc
  from spacy import util
  from thinc.api import Model, Config, get_current_ops, NumpyOps
  from spacy.tests.util import assert_docs_equal
  from .util import DummyTransformer, _assert_equal_tensors
  from ..None import TransformerModel
  from ..pipeline_component import Transformer
  from ..layers import TransformerListener
  from ..data_classes import TransformerData, FullTransformerBatch
label_desc: Use image node_id 12 for calling a global function with example usage: test_transformer_pipeline_tagger_senter_listener() without return types