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: Get the initial attention matrix through the collaborative knowledge graph
  
  Returns:
      torch.sparse.FloatTensor: Sparse tensor of the attention matrix
docstr_tok: ["Get","the","initial","attention","matrix","through","the","collaborative","knowledge","graph","Returns",":","torch.sparse.FloatTensor",":","Sparse","tensor","of","the","attention","matrix"]
code: def init_graph(self):
      r"""Get the initial attention matrix through the collaborative knowledge graph
  
      Returns:
          torch.sparse.FloatTensor: Sparse tensor of the attention matrix
      """
      import dgl
  
      adj_list = []
      for rel_type in range(1, self.n_relations, 1):
          edge_idxs = self.ckg.filter_edges(
              lambda edge: edge.data["relation_id"] == rel_type
          )
          sub_graph = (
              dgl.edge_subgraph(
                  self.ckg, edge_idxs, preserve_nodes=True
              )
              .adjacency_matrix(transpose=False, scipy_fmt="coo")
              .astype("float")
          )
          rowsum = np.array(sub_graph.sum(1))
          d_inv = np.power(rowsum, -1).flatten()
          d_inv[np.isinf(d_inv)] = 0.0
          d_mat_inv = sp.diags(d_inv)
          norm_adj = d_mat_inv.dot(sub_graph).tocoo()
          adj_list.append(norm_adj)
  
      final_adj_matrix = sum(adj_list).tocoo()
      indices = torch.LongTensor(
          [final_adj_matrix.row, final_adj_matrix.col]
      )
      values = torch.FloatTensor(final_adj_matrix.data)
      adj_matrix_tensor = torch.sparse.FloatTensor(
          indices, values, self.matrix_size
      )
      return adj_matrix_tensor.to(self.device)
  
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 2 for calling the KGAT obj's underlying member method code with example usage: obj.init_graph() and returns: adj_matrix_tensor