code: def test_adjacency_field_can_index_with_vocab(self):
      vocab = Vocabulary()
      vocab.add_token_to_namespace("a", namespace="labels")
      vocab.add_token_to_namespace("b", namespace="labels")
      vocab.add_token_to_namespace("c", namespace="labels")
  
      labels = ["a", "b"]
      indices = [(0, 1), (2, 1)]
      adjacency_field = AdjacencyField(indices, self.text, labels)
      adjacency_field.index(vocab)
      tensor = adjacency_field.as_tensor(
          adjacency_field.get_padding_lengths()
      )
      numpy.testing.assert_equal(
          tensor.numpy(),
          numpy.array(
              [
                  [-1, 0, -1, -1, -1],
                  [-1, -1, -1, -1, -1],
                  [-1, 1, -1, -1, -1],
                  [-1, -1, -1, -1, -1],
                  [-1, -1, -1, -1, -1],
              ]
          ),
      )
  
file_path: allennlp/tests/data/fields/adjacency_field_test.py
imports: import pytest
  import numpy
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data.fields import AdjacencyField, TextField
  from allennlp.data.token_indexers import SingleIdTokenIndexer
  from allennlp.data import Vocabulary, Token
label_desc: Use image node_id 2 for calling the TestAdjacencyField obj's underlying member method code with example usage: obj.test_adjacency_field_can_index_with_vocab() without return types