class_docstr: PoolTest
      
class_docstr_tok: ["PoolTest"]
docstr: pgl.nn.SAGPool test
          
docstr_tok: ["pgl.nn.SAGPool","test"]
code: def test_sag_pool(self):
      """pgl.nn.SAGPool test"""
      x = paddle.randn((8, 4))
      batch = paddle.to_tensor(
          [0, 0, 1, 1, 1, 2, 2, 2], dtype=paddle.int64
      )
      edge_index = paddle.to_tensor(
          [
              [0, 1, 2, 3, 4, 5, 5, 6, 6, 7],
              [1, 0, 3, 4, 2, 6, 7, 7, 5, 6],
          ]
      ).transpose([1, 0])
      num_nodes = segment_sum(paddle.ones([x.shape[0]]), batch)
      batch_size = (batch.max() + 1).item()
      graph_node_index = paddle.zeros([batch_size + 1])
      graph_node_index = paddle.scatter(
          graph_node_index,
          paddle.arange(1, batch_size + 1),
          num_nodes.cumsum(0),
      ).astype(paddle.int64)
      g = pgl.Graph(
          num_nodes=8,
          edges=edge_index,
          node_feat={"attr": x},
          _graph_node_index=graph_node_index,
          _num_graph=batch_size,
      ).tensor()
      sag_pool = SAGPool(4, 0.5, pgl.nn.GCNConv)
      output, _, graph = sag_pool(g, x)
      self.assertAlmostEqual(
          output.shape[0],
          math.ceil(0.5 * 2) + math.ceil(0.5 * 3) + math.ceil(0.5 * 3),
      )
      self.assertAlmostEqual(graph.num_graph, 3)
      self.assertAlmostEqual(graph.edges.shape[1], 2)
  
imports: import os
  import sys
  import re
  import time
  import unittest
  import numpy
  import math
  import paddle
  import pgl
  from pgl.utils.logger import log
  from pgl.math import segment_sum
  from pgl.nn import Set2Set, GlobalAttention, SAGPool, GraphPool
  from pgl.nn import GraphMultisetTransformer
label_desc: Use image node_id 4 for calling the PoolTest obj's underlying member method code with example usage: obj.test_sag_pool() without return types