code: def filter_adj(edge_index, perm, edge_attr=None, num_nodes=None):
      """Accoding to the reserved nodes,  updating edges in graph and reindex nodes
  
      Args:
          edge_index (paddle.tensor): The edge_index of graph (shape: [|E|, 2 ])
  
          perm (paddle.tensor): The index of reserved nodes
  
          edge_attr (edge_attr): The attribute of edges. Default: None.
  
          num_nodes: The number of nodes.  Default: None
  
      Returns:
  
          out (paddle.tensor): Returns a udpated edge index tensor (shape = [|E|, 2'])
          edge_attr (paddle.tensor): Return a edge attribute tensor if input edge_attr is not None
  
      """
      num_nodes = maybe_num_nodes(edge_index)
      mask = paddle.full([num_nodes], -1, dtype=paddle.float32)
      i = paddle.arange(perm.shape[0], dtype=paddle.float32)
      mask = paddle.scatter(mask, perm, i)
      mask = mask.astype(paddle.int64)
      row, col = edge_index.transpose([1, 0])
      row, col = mask[row], mask[col]
      mask = (row >= 0).logical_and((col >= 0))
      row, col = row[mask.nonzero()].reshape([-1]), col[
          mask.nonzero()
      ].reshape([-1])
      if edge_attr is not None:
          edge_attr = edge_attr[mask]
      return paddle.stack([row, col], 0).transpose([1, 0]), edge_attr
  
file_path: PGL/pgl/utils/transform.py
imports: import numpy
  import pgl
  import paddle
  from pgl.math import segment_sum
  from pgl.utils.helper import maybe_num_nodes
label_desc: Use image node_id 4 for calling a global function with example usage: filter_adj(edge_index, perm, edge_attr, num_nodes) and returns: paddle,  edge_attr