code: def test_can_build_from_params(self):
      params = Params(
          {"type": "legacy", "similarity_function": {"type": "cosine"}}
      )
      attention = MatrixAttention.from_params(params)
      # pylint: disable=protected-access
      assert (
          attention._similarity_function.__class__.__name__
          == "CosineSimilarity"
      )
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/modules/matrix_attention/legacy_matrix_attention_test.py
imports: from __future__ import absolute_import
  from numpy.testing import assert_allclose
  import torch
  from allennlp.common import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.modules.matrix_attention.legacy_matrix_attention import LegacyMatrixAttention
  from allennlp.modules.matrix_attention.matrix_attention import MatrixAttention
  from allennlp.modules.similarity_functions.dot_product import DotProductSimilarity
label_desc: Use image node_id 2 for calling the TestLegacyMatrixAttention obj's underlying member method code with example usage: obj.test_can_build_from_params() without return types