code: def test_sequence_mask_correct_excluded(self):
      # Check if span indices masked out by the sequence mask are ignored when computing
      # the span representations. For this test span_start is valid, but span_end is masked out.
  
      sequence_tensor = torch.randn([2, 6, 30])
  
      extractor = MaxPoolingSpanExtractor(30)
      indices = torch.LongTensor(
          [[[1, 1], [3, 5], [2, 5]], [[0, 0], [0, 3], [4, 5]]]
      )
      # define sequence mak
      seq_mask = torch.BoolTensor(
          [[True] * 4 + [False] * 2, [True] * 5 + [False] * 1]
      )
  
      span_representations = extractor(
          sequence_tensor, indices, sequence_mask=seq_mask
      )
  
      # After we computed the representations we set values to -inf
      # to compute the "real" max-pooling with python's max function.
      sequence_tensor[torch.logical_not(seq_mask)] = float("-inf")
  
      # Comparison is similar to test_max_values_extracted
      for batch, X in enumerate(indices):
          for indices_ind, span_def in enumerate(X):
              span_features_complete = sequence_tensor[batch][
                  span_def[0] : span_def[1] + 1
              ]
  
              for i, _ in enumerate(span_features_complete):
                  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 3 for calling the TestMaxPoolingSpanExtractor obj's underlying member method code with example usage: obj.test_sequence_mask_correct_excluded() without return types