class_docstr: The Recurrent Event Network model from the `"Recurrent Event Network
  for Reasoning over Temporal Knowledge Graphs"
  <https://arxiv.org/abs/1904.05530>`_ paper.
  
  .. math::
      f_{\mathbf{\Theta}}(\mathbf{e}_s, \mathbf{e}_r,
      \mathbf{h}^{(t-1)}(s, r))
  
  based on a RNN encoder
  
  .. math::
      \mathbf{h}^{(t)}(s, r) = \textrm{RNN}(\mathbf{e}_s, \mathbf{e}_r,
      g(\mathcal{O}^{(t)}_r(s)), \mathbf{h}^{(t-1)}(s, r))
  
  where :math:`\mathbf{e}_s` and :math:`\mathbf{e}_r` denote entity and
  relation embeddings, and :math:`\mathcal{O}^{(t)}_r(s)` represents the set
  of objects interacted with subject :math:`s` under relation :math:`r` at
  timestamp :math:`t`.
  This model implements :math:`g` as the **Mean Aggregator** and
  :math:`f_{\mathbf{\Theta}}` as a linear projection.
  
  Args:
      num_nodes (int): The number of nodes in the knowledge graph.
      num_rels (int): The number of relations in the knowledge graph.
      hidden_channels (int): Hidden size of node and relation embeddings.
      seq_len (int): The sequence length of past events.
      num_layers (int, optional): The number of recurrent layers.
          (default: :obj:`1`)
      dropout (float): If non-zero, introduces a dropout layer before the
          final prediction. (default: :obj:`0.`)
      bias (bool, optional): If set to :obj:`False`, all layers will not
          learn an additive bias. (default: :obj:`True`)
class_docstr_tok: ["The","Recurrent","Event","Network","model","from","the","`","``","Recurrent","Event","Network","for","Reasoning","over","Temporal","Knowledge","Graphs","''","<","https",":","\/\/arxiv.org\/abs\/1904.05530",">","`","_","paper",".","..","math",":",":","f_","{","\\mathbf","{","\\Theta","}","}","(","\\mathbf","{","e","}","_s",",","\\mathbf","{","e","}","_r",",","\\mathbf","{","h","}","^","{","(","t-1",")","}","(","s",",","r",")",")","based","on","a","RNN","encoder","..","math",":",":","\\mathbf","{","h","}","^","{","(","t",")","}","(","s",",","r",")","=","\\textrm","{","RNN","}","(","\\mathbf","{","e","}","_s",",","\\mathbf","{","e","}","_r",",","g","(","\\mathcal","{","O","}","^","{","(","t",")","}","_r","(","s",")",")",",","\\mathbf","{","h","}","^","{","(","t-1",")","}","(","s",",","r",")",")","where",":","math",":","`","\\mathbf","{","e","}","_s","`","and",":","math",":","`","\\mathbf","{","e","}","_r","`","denote","entity","and","relation","embeddings",",","and",":","math",":","`","\\mathcal","{","O","}","^","{","(","t",")","}","_r","(","s",")","`","represents","the","set","of","objects","interacted","with","subject",":","math",":","`","s","`","under","relation",":","math",":","`","r","`","at","timestamp",":","math",":","`","t","`",".","This","model","implements",":","math",":","`","g","`","as","the","*","*","Mean","Aggregator","*","*","and",":","math",":","`","f_","{","\\mathbf","{","\\Theta","}","}","`","as","a","linear","projection",".","Args",":","num_nodes","(","int",")",":","The","number","of","nodes","in","the","knowledge","graph",".","num_rels","(","int",")",":","The","number","of","relations","in","the","knowledge","graph",".","hidden_channels","(","int",")",":","Hidden","size","of","node","and","relation","embeddings",".","seq_len","(","int",")",":","The","sequence","length","of","past","events",".","num_layers","(","int",",","optional",")",":","The","number","of","recurrent","layers",".","(","default",":",":","obj",":","`","1","`",")","dropout","(","float",")",":","If","non-zero",",","introduces","a","dropout","layer","before","the","final","prediction",".","(","default",":",":","obj",":","`","0.","`",")","bias","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","False","`",",","all","layers","will","not","learn","an","additive","bias",".","(","default",":",":","obj",":","`","True","`",")"]
docstr: Given a :obj:`data` batch, computes the forward pass.
  
  Args:
      data (torch_geometric.data.Data): The input data, holding subject
          :obj:`sub`, relation :obj:`rel` and object :obj:`obj`
          information with shape :obj:`[batch_size]`.
          In addition, :obj:`data` needs to hold history information for
          subjects, given by a vector of node indices :obj:`h_sub` and
          their relative timestamps :obj:`h_sub_t` and batch assignments
          :obj:`h_sub_batch`.
          The same information must be given for objects (:obj:`h_obj`,
          :obj:`h_obj_t`, :obj:`h_obj_batch`).
docstr_tok: ["Given","a",":","obj",":","`","data","`","batch",",","computes","the","forward","pass",".","Args",":","data","(","torch_geometric.data.Data",")",":","The","input","data",",","holding","subject",":","obj",":","`","sub","`",",","relation",":","obj",":","`","rel","`","and","object",":","obj",":","`","obj","`","information","with","shape",":","obj",":","`","[","batch_size","]","`",".","In","addition",",",":","obj",":","`","data","`","needs","to","hold","history","information","for","subjects",",","given","by","a","vector","of","node","indices",":","obj",":","`","h_sub","`","and","their","relative","timestamps",":","obj",":","`","h_sub_t","`","and","batch","assignments",":","obj",":","`","h_sub_batch","`",".","The","same","information","must","be","given","for","objects","(",":","obj",":","`","h_obj","`",",",":","obj",":","`","h_obj_t","`",",",":","obj",":","`","h_obj_batch","`",")","."]
code: def forward(self, data: Data) -> Tuple[Tensor, Tensor]:
      """Given a :obj:`data` batch, computes the forward pass.
  
      Args:
          data (torch_geometric.data.Data): The input data, holding subject
              :obj:`sub`, relation :obj:`rel` and object :obj:`obj`
              information with shape :obj:`[batch_size]`.
              In addition, :obj:`data` needs to hold history information for
              subjects, given by a vector of node indices :obj:`h_sub` and
              their relative timestamps :obj:`h_sub_t` and batch assignments
              :obj:`h_sub_batch`.
              The same information must be given for objects (:obj:`h_obj`,
              :obj:`h_obj_t`, :obj:`h_obj_batch`).
      """
      assert "h_sub_batch" in data and "h_obj_batch" in data
      batch_size, seq_len = data.sub.size(0), self.seq_len
  
      h_sub_t = data.h_sub_t + data.h_sub_batch * seq_len
      h_obj_t = data.h_obj_t + data.h_obj_batch * seq_len
  
      h_sub = scatter(
          self.ent[data.h_sub],
          h_sub_t,
          dim=0,
          dim_size=batch_size * seq_len,
          reduce="mean",
      ).view(batch_size, seq_len, -1)
      h_obj = scatter(
          self.ent[data.h_obj],
          h_obj_t,
          dim=0,
          dim_size=batch_size * seq_len,
          reduce="mean",
      ).view(batch_size, seq_len, -1)
  
      sub = self.ent[data.sub].unsqueeze(1).repeat(1, seq_len, 1)
      rel = self.rel[data.rel].unsqueeze(1).repeat(1, seq_len, 1)
      obj = self.ent[data.obj].unsqueeze(1).repeat(1, seq_len, 1)
  
      _, h_sub = self.sub_gru(torch.cat([sub, h_sub, rel], dim=-1))
      _, h_obj = self.obj_gru(torch.cat([obj, h_obj, rel], dim=-1))
      h_sub, h_obj = h_sub.squeeze(0), h_obj.squeeze(0)
  
      h_sub = torch.cat(
          [self.ent[data.sub], h_sub, self.rel[data.rel]], dim=-1
      )
      h_obj = torch.cat(
          [self.ent[data.obj], h_obj, self.rel[data.rel]], dim=-1
      )
  
      h_sub = F.dropout(h_sub, p=self.dropout, training=self.training)
      h_obj = F.dropout(h_obj, p=self.dropout, training=self.training)
  
      log_prob_obj = F.log_softmax(self.sub_lin(h_sub), dim=1)
      log_prob_sub = F.log_softmax(self.obj_lin(h_obj), dim=1)
  
      return log_prob_obj, log_prob_sub
  
file_path: pytorch_geometric/torch_geometric/nn/models/re_net.py
imports: import math
  from typing import Callable, List, Tuple
  import torch
  import torch.nn.functional
  from torch import Tensor
  from torch.nn import GRU, Linear, Parameter
  from torch_geometric.data.data import Data
  from torch_geometric.utils import scatter
label_desc: Use image node_id 4 for calling the RENet obj's underlying member method code with example usage: obj.forward(data) and returns: log_prob_obj,  log_prob_sub