class_docstr: SGL is a GCN-based recommender model.
  
  SGL supplements the classical supervised task of recommendation with an auxiliary
  self supervised task, which reinforces node representation learning via self-
  discrimination.Specifically,SGL generates multiple views of a node, maximizing the
  agreement between different views of the same node compared to that of other nodes.
  SGL devises three operators to generate the views — node dropout, edge dropout, and
  random walk — that change the graph structure in different manners.
  
  We implement the model following the original author with a pairwise training mode.
docstr: Calculate the loss of self-supervised tasks.
  
  Args:
      user_list (torch.Tensor): List of the user.
      pos_item_list (torch.Tensor): List of positive examples.
      user_sub1 (torch.Tensor): Ego embedding of all users in the first subgraph after forwarding.
      user_sub2 (torch.Tensor): Ego embedding of all users in the second subgraph after forwarding.
      item_sub1 (torch.Tensor): Ego embedding of all items in the first subgraph after forwarding.
      item_sub2 (torch.Tensor): Ego embedding of all items in the second subgraph after forwarding.
  
  Returns:
      torch.Tensor: Loss of self-supervised tasks.
docstr_tok: ["Calculate","the","loss","of","self-supervised","tasks",".","Args",":","user_list","(","torch.Tensor",")",":","List","of","the","user",".","pos_item_list","(","torch.Tensor",")",":","List","of","positive","examples",".","user_sub1","(","torch.Tensor",")",":","Ego","embedding","of","all","users","in","the","first","subgraph","after","forwarding",".","user_sub2","(","torch.Tensor",")",":","Ego","embedding","of","all","users","in","the","second","subgraph","after","forwarding",".","item_sub1","(","torch.Tensor",")",":","Ego","embedding","of","all","items","in","the","first","subgraph","after","forwarding",".","item_sub2","(","torch.Tensor",")",":","Ego","embedding","of","all","items","in","the","second","subgraph","after","forwarding",".","Returns",":","torch.Tensor",":","Loss","of","self-supervised","tasks","."]
code: def calc_ssl_loss(
      self,
      user_list,
      pos_item_list,
      user_sub1,
      user_sub2,
      item_sub1,
      item_sub2,
  ):
      r"""Calculate the loss of self-supervised tasks.
  
      Args:
          user_list (torch.Tensor): List of the user.
          pos_item_list (torch.Tensor): List of positive examples.
          user_sub1 (torch.Tensor): Ego embedding of all users in the first subgraph after forwarding.
          user_sub2 (torch.Tensor): Ego embedding of all users in the second subgraph after forwarding.
          item_sub1 (torch.Tensor): Ego embedding of all items in the first subgraph after forwarding.
          item_sub2 (torch.Tensor): Ego embedding of all items in the second subgraph after forwarding.
  
      Returns:
          torch.Tensor: Loss of self-supervised tasks.
      """
  
      u_emd1 = F.normalize(user_sub1[user_list], dim=1)
      u_emd2 = F.normalize(user_sub2[user_list], dim=1)
      all_user2 = F.normalize(user_sub2, dim=1)
      v1 = torch.sum(u_emd1 * u_emd2, dim=1)
      v2 = u_emd1.matmul(all_user2.T)
      v1 = torch.exp(v1 / self.ssl_tau)
      v2 = torch.sum(torch.exp(v2 / self.ssl_tau), dim=1)
      ssl_user = -torch.sum(torch.log(v1 / v2))
  
      i_emd1 = F.normalize(item_sub1[pos_item_list], dim=1)
      i_emd2 = F.normalize(item_sub2[pos_item_list], dim=1)
      all_item2 = F.normalize(item_sub2, dim=1)
      v3 = torch.sum(i_emd1 * i_emd2, dim=1)
      v4 = i_emd1.matmul(all_item2.T)
      v3 = torch.exp(v3 / self.ssl_tau)
      v4 = torch.sum(torch.exp(v4 / self.ssl_tau), dim=1)
      ssl_item = -torch.sum(torch.log(v3 / v4))
  
      return (ssl_item + ssl_user) * self.ssl_weight
  
imports: import numpy
  import scipy.sparse
  import torch
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.init import xavier_uniform_initialization
  from recbole.model.loss import BPRLoss, EmbLoss
  from recbole.utils import InputType
  import torch.nn.functional
label_desc: Use image node_id 9 for calling the SGL obj's underlying member method code with example usage: obj.calc_ssl_loss(user_list, pos_item_list, user_sub1, user_sub2, item_sub1, item_sub2) and returns: unknown