docstr: The calculation method of attention weight here follows the code implementation of the author, which is
  slightly different from that described in the paper.
docstr_tok: ["The","calculation","method","of","attention","weight","here","follows","the","code","implementation","of","the","author",",","which","is","slightly","different","from","that","described","in","the","paper","."]
code: def calculate_sim_hrt(
      self, entity_emb_head, entity_emb_tail, relation_emb
  ):
      r"""
      The calculation method of attention weight here follows the code implementation of the author, which is
      slightly different from that described in the paper.
      """
      tail_relation_emb = entity_emb_tail * relation_emb
      tail_relation_emb = tail_relation_emb.norm(
          dim=1, p=2, keepdim=True
      )
      head_relation_emb = entity_emb_head * relation_emb
      head_relation_emb = head_relation_emb.norm(
          dim=1, p=2, keepdim=True
      )
      # [-1, 1, embedding_size] * [-1, embedding_size, 1] -> [-1, 1]
      att_weights = torch.matmul(
          head_relation_emb.unsqueeze(dim=1),
          tail_relation_emb.unsqueeze(dim=2),
      ).squeeze(dim=-1)
      att_weights = att_weights**2
      return att_weights
  
imports: import numpy
  import scipy.sparse
  import torch
  import torch.nn
  import torch.nn.functional
  from recbole.model.abstract_recommender import KnowledgeRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.model.layers import SparseDropout
  from recbole.model.loss import BPRLoss, EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 3 for calling the Aggregator obj's underlying member method code with example usage: obj.calculate_sim_hrt(entity_emb_head, entity_emb_tail, relation_emb) and returns: att_weights