code: def test_get_entity_action_logits(self):
      decoder_step = WikiTablesDecoderStep(
          1, 5, SimilarityFunction.from_params(Params({})), 5, 3
      )
      actions_to_link = [[1, 2], [3, 4, 5], [6]]
      # (group_size, num_question_tokens) = (3, 3)
      attention_weights = torch.Tensor(
          [[0.2, 0.8, 0], [0.7, 0.1, 0.2], [0.3, 0.3, 0.4]]
      )
      (
          action_logits,
          mask,
          type_embeddings,
      ) = decoder_step._get_entity_action_logits(
          self.state, actions_to_link, attention_weights
      )
      assert_almost_equal(
          mask.detach().cpu().numpy(), [[1, 1, 0], [1, 1, 1], [1, 0, 0]]
      )
  
      assert tuple(action_logits.size()) == (3, 3)
      assert_almost_equal(
          action_logits[0, 0].detach().cpu().numpy(),
          0.4 * 0.2 + 0.5 * 0.8 + 0.6 * 0,
      )
      assert_almost_equal(
          action_logits[0, 1].detach().cpu().numpy(),
          0.7 * 0.2 + 0.8 * 0.8 + 0.9 * 0,
      )
      assert_almost_equal(
          action_logits[1, 0].detach().cpu().numpy(),
          -0.4 * 0.7 + -0.5 * 0.1 + -0.6 * 0.2,
      )
      assert_almost_equal(
          action_logits[1, 1].detach().cpu().numpy(),
          -0.7 * 0.7 + -0.8 * 0.1 + -0.9 * 0.2,
      )
      assert_almost_equal(
          action_logits[1, 2].detach().cpu().numpy(),
          -1.0 * 0.7 + -1.1 * 0.1 + -1.2 * 0.2,
      )
      assert_almost_equal(
          action_logits[2, 0].detach().cpu().numpy(),
          1.0 * 0.3 + 1.1 * 0.3 + 1.2 * 0.4,
      )
  
      embedding_matrix = (
          decoder_step._entity_type_embedding.weight.detach()
          .cpu()
          .numpy()
      )
      assert_almost_equal(
          type_embeddings[0, 0].detach().cpu().numpy(),
          embedding_matrix[2],
      )
      assert_almost_equal(
          type_embeddings[0, 1].detach().cpu().numpy(),
          embedding_matrix[1],
      )
      assert_almost_equal(
          type_embeddings[1, 0].detach().cpu().numpy(),
          embedding_matrix[0],
      )
      assert_almost_equal(
          type_embeddings[1, 1].detach().cpu().numpy(),
          embedding_matrix[1],
      )
      assert_almost_equal(
          type_embeddings[1, 2].detach().cpu().numpy(),
          embedding_matrix[2],
      )
      assert_almost_equal(
          type_embeddings[2, 0].detach().cpu().numpy(),
          embedding_matrix[0],
      )
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/models/semantic_parsing/wikitables/wikitables_decoder_step_test.py
imports: from __future__ import absolute_import
  from numpy.testing import assert_almost_equal
  import torch
  from allennlp.common import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.models.semantic_parsing.wikitables.wikitables_decoder_state import WikiTablesDecoderState
  from allennlp.models.semantic_parsing.wikitables.wikitables_decoder_step import WikiTablesDecoderStep
  from allennlp.modules import SimilarityFunction
  from allennlp.nn.decoding import GrammarState, RnnState
  from allennlp.semparse.type_declarations.type_declaration import is_nonterminal
label_desc: Use image node_id 5 for calling the WikiTablesDecoderStepTest obj's underlying member method code with example usage: obj.test_get_entity_action_logits() without return types