code: def test_as_array_produces_token_array(self):
      indexer = SpacyTokenIndexer()
      nlp = get_spacy_model("en_core_web_sm", parse=False, ner=False)
      tokens = [t for t in nlp("This is a sentence.")]
      field = TextField(tokens, token_indexers={"spacy": indexer})
  
      vocab = Vocabulary()
      field.index(vocab)
  
      # Indexer functionality
      array_dict = indexer.tokens_to_indices(tokens, vocab)
      assert len(array_dict["tokens"]) == 5
      assert len(array_dict["tokens"][0]) == 96
  
      # Check it also works with field
      lengths = field.get_padding_lengths()
      array_dict = field.as_tensor(lengths)
  
      assert list(array_dict["spacy"]["tokens"].shape) == [5, 96]
  
file_path: allennlp/tests/data/token_indexers/spacy_indexer_test.py
imports: from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data.token_indexers.spacy_indexer import SpacyTokenIndexer
  from allennlp.data.fields.text_field import TextField
  from allennlp.common.util import get_spacy_model
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 1 for calling the TestSpacyTokenIndexer obj's underlying member method code with example usage: obj.test_as_array_produces_token_array() without return types