code: def build_edges(num_nodes, input_mask, max_seqlen):
      edges = L.range(start=0, end=num_nodes, step=1, dtype="int32")
      all_edges = []
      # Window
      filter_func = lambda x, y: select_edges(
          x, y, input_mask, num_nodes, max_seqlen
      )
  
      all_edges.append(filter_func(edges - 1, edges))  # win-1
      all_edges.append(filter_func(edges + 1, edges))  # win-2
      all_edges.append(filter_func(edges, edges))  # self-loop
  
      # Global Assume [CLS] is the first token.
  
      # vertical cls-window attention
      cls_position = edges / max_seqlen * max_seqlen
      all_edges.append(filter_func(cls_position, edges))
  
      # horizontal cls attention
      all_edges.append(filter_func(edges, cls_position))
  
      # Random
      for i in range(2):
          rand_edge = L.floor(
              L.uniform_random(min=0, max=1, shape=[num_nodes])
              * L.cast(max_seqlen, dtype="float32")
          )
          rand_edge = L.cast(rand_edge, dtype="int32") + cls_position
          all_edges.append(filter_func(rand_edge, edges))
  
      if len(all_edges) > 1:
          src = L.concat([s for s, d in all_edges], 0)
          dst = L.concat([d for s, d in all_edges], 0)
      else:
          src = all_edges[0][0]
          dst = all_edges[0][1]
  
      # sort edges
      sorted_src, sorted_dst = uniq_edges(src, dst, num_nodes)
      return sorted_src, sorted_dst
  
file_path: PGL/legacy/examples/xformer/sparse_scaled_dot_product_attention.py
imports: import paddle.fluid
  import paddle.fluid.layers
  import paddle.fluid.layers
  from pgl.utils import paddle_helper
  import pgl
label_desc: Use image node_id 4 for calling a global function with example usage: build_edges(num_nodes, input_mask, max_seqlen) and returns: sorted_src,  sorted_dst