code: def doc_w_attrs(en_tokenizer):
      Doc.set_extension("_test_attr", default=False)
      Doc.set_extension("_test_prop", getter=lambda doc: len(doc.text))
      Doc.set_extension(
          "_test_method",
          method=lambda doc, arg: f"{len(doc.text)}{arg}",
      )
      doc = en_tokenizer("This is a test.")
      doc._._test_attr = "test"
  
      Token.set_extension("_test_token", default="t0")
      doc[1]._._test_token = "t1"
  
      return doc
  
imports: import pytest
  from spacy.tokens import Doc, Token
  from spacy.vocab import Vocab
label_desc: Use image node_id 1 for calling a global function with example usage: doc_w_attrs(en_tokenizer) and returns: doc