code: def test_batch_tensors(self):
      self.field.index(self.vocab)
      padding_lengths = self.field.get_padding_lengths()
      tensor_dict1 = self.field.as_tensor(padding_lengths)
      tensor_dict2 = self.field.as_tensor(padding_lengths)
      batched_tensor_dict = self.field.batch_tensors(
          [tensor_dict1, tensor_dict2]
      )
      assert list(batched_tensor_dict.keys()) == set(
          ["text", "linking"]
      )
      expected_single_tensor = [
          [self.negative_one_index, 0, 0],
          [self.zero_index, 0, 0],
          [self.one_index, 0, 0],
          [self.edirne_index, 0, 0],
          [self.lake_index, self.gala_index, 0],
          [self.mersin_index, 0, 0],
          [self.paradeniz_index, 0, 0],
          [self.location_index, self.in_index, self.english_index],
          [self.name_index, self.in_index, self.english_index],
      ]
      expected_batched_tensor = [
          expected_single_tensor,
          expected_single_tensor,
      ]
      assert_almost_equal(
          batched_tensor_dict["text"]["tokens"].detach().cpu().numpy(),
          expected_batched_tensor,
      )
      expected_linking_tensor = torch.stack(
          [tensor_dict1["linking"], tensor_dict2["linking"]]
      )
      assert_almost_equal(
          batched_tensor_dict["linking"].detach().cpu().numpy(),
          expected_linking_tensor.detach().cpu().numpy(),
      )
  
imports: from __future__ import division
  from __future__ import with_statement
  from __future__ import absolute_import
  from collections import defaultdict
  import pytest
  from numpy.testing import assert_almost_equal
  import torch
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Vocabulary
  from allennlp.data.fields import KnowledgeGraphField
  from allennlp.data.token_indexers import SingleIdTokenIndexer, TokenCharactersIndexer
  from allennlp.data.tokenizers import WordTokenizer
  from allennlp.data.tokenizers.word_splitter import SpacyWordSplitter
  from allennlp.semparse.contexts import TableQuestionKnowledgeGraph
label_desc: Use image node_id 9 for calling the KnowledgeGraphFieldTest obj's underlying member method code with example usage: obj.test_batch_tensors() without return types