class_docstr: EGESModel
      
class_docstr_tok: ["EGESModel"]
docstr: forward
          
docstr_tok: ["forward"]
code: def forward(self):
      """forward"""
      src, dst = L.read_file(self.pyreader)
  
      src_id = L.slice(
          src,
          [0, 1, 2, 3],
          [0, 0, 0, 0],
          [int(math.pow(2, 30)) - 1, 1, 1, 1],
      )
      dst_id = L.slice(
          dst,
          [0, 1, 2, 3],
          [0, 0, 0, 0],
          [int(math.pow(2, 30)) - 1, self.neg_num + 1, 1, 1],
      )
  
      if self.is_sparse:
          # sparse mode use 2 dims input.
          src = L.reshape(src, [-1, 1])
          dst = L.reshape(dst, [-1, 1])
  
      # [b, 1, f, h]
      src_embed = split_embedding(
          src,
          self.num_nodes,
          self.hidden_size,
          self.embed_init,
          "weight",
          self.num_part,
          self.is_sparse,
      )
  
      # [b, n+1, f, h]
      dst_embed = split_embedding(
          dst,
          self.num_nodes,
          self.hidden_size,
          self.embed_init,
          "weight",
          self.num_part,
          self.is_sparse,
      )
  
      if self.is_sparse:
          src_embed = L.reshape(
              src_embed, [-1, 1, self.num_featuers, self.hidden_size]
          )
          dst_embed = L.reshape(
              dst_embed,
              [
                  -1,
                  self.neg_num + 1,
                  self.num_featuers,
                  self.hidden_size,
              ],
          )
  
      # [b, 1, 1, f]
      src_weight = L.softmax(
          L.embedding(
              src_id,
              [self.num_nodes, self.num_featuers],
              param_attr=F.ParamAttr(name="alpha"),
          )
      )
      # [b, n+1, 1, f]
      dst_weight = L.softmax(
          L.embedding(
              dst_id,
              [self.num_nodes, self.num_featuers],
              param_attr=F.ParamAttr(name="alpha"),
          )
      )
  
      # [b, 1, h]
      src_sum = L.squeeze(L.matmul(src_weight, src_embed), axes=[2])
      # [b, n+1, h]
      dst_sum = L.squeeze(L.matmul(dst_weight, dst_embed), axes=[2])
  
      logits = L.matmul(
          src_sum, dst_sum, transpose_y=True
      )  # [batch_size, 1, neg_num+1]
  
      pos_label = L.fill_constant_batch_size_like(
          logits, [-1, 1, 1], "float32", 1
      )
      neg_label = L.fill_constant_batch_size_like(
          logits, [-1, 1, self.neg_num], "float32", 0
      )
      label = L.concat([pos_label, neg_label], -1)
  
      pos_weight = L.fill_constant_batch_size_like(
          logits, [-1, 1, 1], "float32", self.neg_num
      )
      neg_weight = L.fill_constant_batch_size_like(
          logits, [-1, 1, self.neg_num], "float32", 1
      )
      weight = L.concat([pos_weight, neg_weight], -1)
  
      weight.stop_gradient = True
      label.stop_gradient = True
  
      loss = L.sigmoid_cross_entropy_with_logits(logits, label)
      loss = loss * weight
      loss = L.reduce_mean(loss)
      loss = loss * ((self.neg_num + 1) / 2 / self.neg_num)
      loss.persistable = True
      self.loss = loss
      return loss
  
file_path: PGL/legacy/examples/ges/model.py
imports: from __future__ import division
  from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import unicode_literals
  import math
  import paddle.fluid.layers
  import paddle.fluid
label_desc: Use image node_id 1 for calling the EGESModel obj's underlying member method code with example usage: obj.forward() and returns: loss