code: def test_constructor_asserts_multi_head_consistency(self):
      with pytest.raises(ConfigurationError) as exception_info:
          IntraSentenceAttentionEncoder(
              input_dim=5, num_attention_heads=4
          )
      assert (
          "Encoder has multiple heads" in exception_info.value.message
      )
      similarity = MultiHeadedSimilarity(3, 6)
      with pytest.raises(ConfigurationError) as exception_info:
          IntraSentenceAttentionEncoder(
              input_dim=5, similarity_function=similarity
          )
      assert (
          "Similarity function has multiple heads"
          in exception_info.value.message
      )
      with pytest.raises(ConfigurationError) as exception_info:
          IntraSentenceAttentionEncoder(
              input_dim=5,
              num_attention_heads=2,
              similarity_function=similarity,
          )
      assert (
          "Number of heads don't match" in exception_info.value.message
      )
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/modules/seq2seq_encoders/intra_sentence_attention_test.py
imports: from __future__ import with_statement
  from __future__ import absolute_import
  import numpy
  import pytest
  import torch
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.modules.seq2seq_encoders import IntraSentenceAttentionEncoder
  from allennlp.modules.similarity_functions import MultiHeadedSimilarity
label_desc: Use image node_id 2 for calling the TestIntraSentenceAttentionEncoder obj's underlying member method code with example usage: obj.test_constructor_asserts_multi_head_consistency() without return types