class_docstr: Computes attention between a vector and a matrix using cosine similarity.
class_docstr_tok: ["Computes","attention","between","a","vector","and","a","matrix","using","cosine","similarity","."]
code: def _forward_internal(self, vector, matrix):
      a_norm = vector / (vector.norm(p=2, dim=-1, keepdim=True) + 1e-13)
      b_norm = matrix / (matrix.norm(p=2, dim=-1, keepdim=True) + 1e-13)
      return torch.bmm(
          a_norm.unsqueeze(dim=1), b_norm.transpose(-1, -2)
      ).squeeze(1)
  
imports: from __future__ import division
  from __future__ import absolute_import
  import torch
  from allennlp.modules.attention.legacy_attention import Attention
label_desc: Use image node_id 1 for calling the CosineAttention obj's underlying member method code with example usage: obj._forward_internal(vector, matrix) and returns: torch