code: def test_transformer_pipeline_empty():
      """Test that the pipeline doesn't fail with empty input"""
      orig_config = Config().from_str(cfg_string)
      nlp = util.load_model_from_config(
          orig_config, auto_fill=True, validate=True
      )
      tagger = nlp.get_pipe("tagger")
      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)
  
      # train on empty doc
      optimizer = nlp.initialize()
      losses = {}
      empty_train_example = Example.from_dict(nlp.make_doc(""), {})
      nlp.update(train_examples, sgd=optimizer, losses=losses)
      nlp.update([empty_train_example], sgd=optimizer, losses=losses)
      train_examples.append(empty_train_example)
      nlp.update(train_examples, sgd=optimizer, losses=losses)
      # Interleave an empty doc between non-empty ones
      train_examples.insert(1, Example.from_dict(nlp.make_doc(""), {}))
      nlp.update(train_examples, sgd=optimizer, losses=losses)
  
      # predict empty doc
      doc = nlp("")
      _assert_empty(doc._.trf_data)
      docs = nlp.pipe(["", ""])
      for doc in docs:
          _assert_empty(doc._.trf_data)
      nlp.pipe([])
  
      # predict combination of empty and non-empty
      doc = nlp("This is a sentence")
      normal_tags = [t.tag_ for t in doc]
  
      docs = list(nlp.pipe(["", "This is a sentence", "", ""]))
      _assert_empty(docs[0]._.trf_data)
      assert [t.tag_ for t in docs[0]] == []
      assert [t.tag_ for t in docs[1]] == normal_tags
      _assert_empty(docs[2]._.trf_data)
      _assert_empty(docs[3]._.trf_data)
  
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 14 for calling a global function with example usage: test_transformer_pipeline_empty() without return types