class_docstr: A Luong-style attention that also includes the inner product of targets-lookup.
code: def get_attention_vector(
      self,
      lookup_vectors: torch.Tensor,
      memories: torch.Tensor,
      memories_length: torch.Tensor,
  ) -> torch.Tensor:
      # memories: [B, max-inp-len, H]
      # memories_length: [B]
      # look_up_vectors: [B, max-out-len, D]
      # Output: [B, max-out-len, max-inp-len]
      memories_in_d = torch.einsum(
          "blh,hd->bld", memories, self.__Whd
      )  # [B, max-inp-len, D]
      logits = torch.einsum(
          "bld,bqd->bql", memories_in_d, lookup_vectors
      )  # [B, max-out-len, max-inp-len]
  
      mask = (
          torch.arange(memories.shape[1], device=self.device).view(
              1, -1
          )
          >= memories_length.view(-1, 1)
      ).unsqueeze(
          1
      )  # [B, 1, max-inp-len]
      logits.masked_fill_(mask, -math.inf)
      attention = nn.functional.softmax(logits, dim=-1)  # [B, max-len]
      return attention
  
file_path: ptgnn/ptgnn/neuralmodels/sequence/luongattention.py
imports: import math
  import torch
  from torch import nn
label_desc: Use image node_id 4 for calling the LuongAttentionModule obj's underlying member method code with example usage: obj.get_attention_vector(lookup_vectors, memories, memories_length) and returns: attention