code: def test_can_build_from_params(self):
      params = Params(
          {
              "similarity_function": {"type": "cosine"},
              "normalize": False,
          }
      )
      attention = LegacyAttention.from_params(params)
      # pylint: disable=protected-access
      assert (
          attention._similarity_function.__class__.__name__
          == "CosineSimilarity"
      )
      assert attention._normalize is False
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/modules/attention/legacy_attention_test.py
imports: from __future__ import absolute_import
  import numpy
  from numpy.testing import assert_almost_equal
  import torch
  from allennlp.common import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.modules.attention.attention import Attention
  from allennlp.modules.attention.legacy_attention import LegacyAttention
label_desc: Use image node_id 7 for calling the TestLegacyAttention obj's underlying member method code with example usage: obj.test_can_build_from_params() without return types