code: def test_max_values_extracted(self):
      # Test if max_pooling is correctly applied
      # We use a high dimensional random vector and assume that a randomly correct result is too unlikely
      sequence_tensor = torch.randn([2, 10, 30])
      extractor = MaxPoolingSpanExtractor(30)
  
      indices = torch.LongTensor(
          [[[1, 1], [2, 4], [9, 9]], [[0, 1], [4, 4], [0, 9]]]
      )
      span_representations = extractor(sequence_tensor, indices)
  
      assert list(span_representations.size()) == [2, 3, 30]
      assert extractor.get_output_dim() == 30
      assert extractor.get_input_dim() == 30
  
      # We iterate over the tensor to compare the span extractors's results
      # with the results of python max operation over each dimension for each span and for each batch
      # For each batch
      for batch, X in enumerate(indices):
          # For each defined span index
          for indices_ind, span_def in enumerate(X):
              # original features of current tested span
              # span_width x embedding dim (30)
              span_features_complete = sequence_tensor[batch][
                  span_def[0] : span_def[1] + 1
              ]
  
              # comparison for each dimension
              for i in range(extractor.get_output_dim()):
                  # get the features for dimension i of current span
                  features_from_span = span_features_complete[:, i]
                  real_max_value = max(features_from_span)
  
                  extracted_max_value = span_representations[
                      batch, indices_ind, i
                  ]
  
                  assert real_max_value == extracted_max_value, (
                      f"Error extracting max value for "
                      f"batch {batch}, span {indices_ind} on dimension {i}."
                      f"expected {real_max_value} "
                      f"but got {extracted_max_value} which is "
                      f"not the maximum element."
                  )
  
file_path: allennlp/tests/modules/span_extractors/max_pooling_span_extractor_test.py
imports: import pytest
  import torch
  from allennlp.common.params import Params
  from allennlp.modules.span_extractors import SpanExtractor
  from allennlp.modules.span_extractors.max_pooling_span_extractor import MaxPoolingSpanExtractor
label_desc: Use image node_id 2 for calling the TestMaxPoolingSpanExtractor obj's underlying member method code with example usage: obj.test_max_values_extracted() without return types