class_docstr: KGAT is a knowledge-based recommendation model. It combines knowledge graph and the user-item interaction
  graph to a new graph called collaborative knowledge graph (CKG). This model learns the representations of users and
  items by exploiting the structure of CKG. It adopts a GNN-based architecture and define the attention on the CKG.
class_docstr_tok: ["KGAT","is","a","knowledge-based","recommendation","model",".","It","combines","knowledge","graph","and","the","user-item","interaction","graph","to","a","new","graph","called","collaborative","knowledge","graph","(","CKG",")",".","This","model","learns","the","representations","of","users","and","items","by","exploiting","the","structure","of","CKG",".","It","adopts","a","GNN-based","architecture","and","define","the","attention","on","the","CKG","."]
docstr: Calculating scores for triples in KG.
  
  Args:
      hs (torch.Tensor): head entities
      ts (torch.Tensor): tail entities
      r (int): the relation id between hs and ts
  
  Returns:
      torch.Tensor: the scores of (hs, r, ts)
docstr_tok: ["Calculating","scores","for","triples","in","KG",".","Args",":","hs","(","torch.Tensor",")",":","head","entities","ts","(","torch.Tensor",")",":","tail","entities","r","(","int",")",":","the","relation","id","between","hs","and","ts","Returns",":","torch.Tensor",":","the","scores","of","(","hs",",","r",",","ts",")"]
code: def generate_transE_score(self, hs, ts, r):
      r"""Calculating scores for triples in KG.
  
      Args:
          hs (torch.Tensor): head entities
          ts (torch.Tensor): tail entities
          r (int): the relation id between hs and ts
  
      Returns:
          torch.Tensor: the scores of (hs, r, ts)
      """
  
      all_embeddings = self._get_ego_embeddings()
      h_e = all_embeddings[hs]
      t_e = all_embeddings[ts]
      r_e = self.relation_embedding.weight[r]
      r_trans_w = self.trans_w.weight[r].view(
          self.embedding_size, self.kg_embedding_size
      )
  
      h_e = torch.matmul(h_e, r_trans_w)
      t_e = torch.matmul(t_e, r_trans_w)
  
      kg_score = torch.mul(t_e, self.tanh(h_e + r_e)).sum(dim=1)
  
      return kg_score
  
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.loss import BPRLoss, EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 8 for calling the KGAT obj's underlying member method code with example usage: obj.generate_transE_score(hs, ts, r) and returns: kg_score