code: def test_forward_works_with_higher_order_tensors(self):
      # pylint: disable=protected-access
      bilinear = BilinearSimilarity(4, 7)
      weights = numpy.random.rand(4, 7)
      bilinear._weight_matrix = Parameter(
          torch.from_numpy(weights).float()
      )
      bilinear._bias = Parameter(
          torch.from_numpy(numpy.asarray([0])).float()
      )
      a_vectors = numpy.random.rand(5, 4, 3, 6, 4)
      b_vectors = numpy.random.rand(5, 4, 3, 6, 7)
      a_variables = torch.from_numpy(a_vectors).float()
      b_variables = torch.from_numpy(b_vectors).float()
      result = bilinear(a_variables, b_variables).data.numpy()
      assert result.shape == (5, 4, 3, 6)
      expected_result = numpy.dot(
          numpy.dot(numpy.transpose(a_vectors[3, 2, 1, 3]), weights),
          b_vectors[3, 2, 1, 3],
      )
      assert_almost_equal(
          result[3, 2, 1, 3], expected_result, decimal=5
      )
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/modules/similarity_functions/bilinear_test.py
imports: from __future__ import absolute_import
  import numpy
  from numpy.testing import assert_almost_equal
  import torch
  from torch.nn.parameter import Parameter
  from allennlp.common import Params
  from allennlp.modules.similarity_functions import BilinearSimilarity
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 3 for calling the TestBilinearSimilarityFunction obj's underlying member method code with example usage: obj.test_forward_works_with_higher_order_tensors() without return types