code: def test_correct_sequence_elements_are_embedded(self):
      sequence_tensor = torch.randn([2, 5, 7])
      # Concatentate start and end points together to form our representation.
      extractor = EndpointSpanExtractor(7, "x,y")
  
      indices = torch.LongTensor([[[1, 3], [2, 4]], [[0, 2], [3, 4]]])
      span_representations = extractor(sequence_tensor, indices)
  
      assert list(span_representations.size()) == [2, 2, 14]
      assert extractor.get_output_dim() == 14
      assert extractor.get_input_dim() == 7
  
      start_indices, end_indices = indices.split(1, -1)
      # We just concatenated the start and end embeddings together, so
      # we can check they match the original indices if we split them apart.
      start_embeddings, end_embeddings = span_representations.split(
          7, -1
      )
  
      correct_start_embeddings = batched_index_select(
          sequence_tensor, start_indices.squeeze()
      )
      correct_end_embeddings = batched_index_select(
          sequence_tensor, end_indices.squeeze()
      )
      numpy.testing.assert_array_equal(
          start_embeddings.data.numpy(),
          correct_start_embeddings.data.numpy(),
      )
      numpy.testing.assert_array_equal(
          end_embeddings.data.numpy(),
          correct_end_embeddings.data.numpy(),
      )
  
file_path: allennlp/tests/modules/span_extractors/endpoint_span_extractor_test.py
imports: import numpy
  import torch
  from allennlp.modules.span_extractors import SpanExtractor, EndpointSpanExtractor
  from allennlp.common.params import Params
  from allennlp.nn.util import batched_index_select
label_desc: Use image node_id 2 for calling the TestEndpointSpanExtractor obj's underlying member method code with example usage: obj.test_correct_sequence_elements_are_embedded() without return types