class_docstr:     GRACE model
  Parameters
  -----------
  in_dim: int
      Input feature size.
  hid_dim: int
      Hidden feature size.
  out_dim: int
      Output feature size.
  num_layers: int
      Number of the GNN encoder layers.
  act_fn: nn.Module
      Activation function.
  temp: float
      Temperature constant.
class_docstr_tok: ["GRACE","model","Parameters","--","--","--","--","--","-","in_dim",":","int","Input","feature","size",".","hid_dim",":","int","Hidden","feature","size",".","out_dim",":","int","Output","feature","size",".","num_layers",":","int","Number","of","the","GNN","encoder","layers",".","act_fn",":","nn.Module","Activation","function",".","temp",":","float","Temperature","constant","."]
code: def get_loss(self, z1, z2):
      # calculate SimCLR loss
      f = lambda x: th.exp(x / self.temp)
  
      refl_sim = f(self.sim(z1, z1))  # intra-view pairs
      between_sim = f(self.sim(z1, z2))  # inter-view pairs
  
      # between_sim.diag(): positive pairs
      x1 = refl_sim.sum(1) + between_sim.sum(1) - refl_sim.diag()
      loss = -th.log(between_sim.diag() / x1)
  
      return loss
  
file_path: dgl/examples/pytorch/grace/model.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from dgl.nn import GraphConv
label_desc: Use image node_id 3 for calling the Grace obj's underlying member method code with example usage: obj.get_loss(z1, z2) and returns: loss