class_docstr: DGCF is a disentangled representation enhanced matrix factorization model.
  The interaction matrix of :math:`n_{users} \times n_{items}` is decomposed to :math:`n_{factors}` intent graph,
  we carefully design the data interface and use sparse tensor to train and test efficiently.
  We implement the model following the original author with a pairwise training mode.
code: def __init__(self, config, dataset):
      super(DGCF, self).__init__(config, dataset)
  
      # load dataset info
      self.interaction_matrix = dataset.inter_matrix(form="coo").astype(
          np.float32
      )
  
      # load parameters info
      self.embedding_size = config["embedding_size"]
      self.n_factors = config["n_factors"]
      self.n_iterations = config["n_iterations"]
      self.n_layers = config["n_layers"]
      self.reg_weight = config["reg_weight"]
      self.cor_weight = config["cor_weight"]
      n_batch = dataset.inter_num // config["train_batch_size"] + 1
      self.cor_batch_size = int(
          max(self.n_users / n_batch, self.n_items / n_batch)
      )
      # ensure embedding can be divided into <n_factors> intent
      assert self.embedding_size % self.n_factors == 0
  
      # generate intermediate data
      row = self.interaction_matrix.row.tolist()
      col = self.interaction_matrix.col.tolist()
      col = [item_index + self.n_users for item_index in col]
      all_h_list = row + col  # row.extend(col)
      all_t_list = col + row  # col.extend(row)
      num_edge = len(all_h_list)
      edge_ids = range(num_edge)
      self.all_h_list = torch.LongTensor(all_h_list).to(self.device)
      self.all_t_list = torch.LongTensor(all_t_list).to(self.device)
      self.edge2head = torch.LongTensor([all_h_list, edge_ids]).to(
          self.device
      )
      self.head2edge = torch.LongTensor([edge_ids, all_h_list]).to(
          self.device
      )
      self.tail2edge = torch.LongTensor([edge_ids, all_t_list]).to(
          self.device
      )
      val_one = torch.ones_like(self.all_h_list).float().to(self.device)
      num_node = self.n_users + self.n_items
      self.edge2head_mat = self._build_sparse_tensor(
          self.edge2head, val_one, (num_node, num_edge)
      )
      self.head2edge_mat = self._build_sparse_tensor(
          self.head2edge, val_one, (num_edge, num_node)
      )
      self.tail2edge_mat = self._build_sparse_tensor(
          self.tail2edge, val_one, (num_edge, num_node)
      )
      self.num_edge = num_edge
      self.num_node = num_node
  
      # define layers and loss
      self.user_embedding = nn.Embedding(
          self.n_users, self.embedding_size
      )
      self.item_embedding = nn.Embedding(
          self.n_items, self.embedding_size
      )
      self.softmax = torch.nn.Softmax(dim=1)
      self.mf_loss = BPRLoss()
      self.reg_loss = EmbLoss()
      self.restore_user_e = None
      self.restore_item_e = None
  
      self.other_parameter_name = ["restore_user_e", "restore_item_e"]
      # parameters initialization
      self.apply(xavier_normal_initialization)
  
imports: import random
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.autograd import Variable
  from recbole.model.abstract_recommender import GeneralRecommender
  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 1 to create a new DGCF object from inherited base classes: GeneralRecommender with example: obj = DGCF(config, dataset)