class_docstr: Implementation of bigraph interface in pgl.
  
  This is a simple implementation of graph structure in pgl. 
  
  `pgl.BiGraph` is an alias for `pgl.graph.BiGraph` 
  
  Args:
  
      edges: list of (u, v) tuples, 2D numpy.ndarry or 2D paddle.Tensor 
  
      src_num_nodes (optional: int, numpy or paddle.Tensor): Number of src_nodes in a bigraph. 
                         If not provided, the number of src nodes will be infered from edges[:, 0]. 
      dst_num_nodes (optional: int, numpy or paddle.Tensor): Number of dst nodes in a bigraph. 
                         If not provided, the number of dst_nodes will be infered from edges[:, 1]. 
  
      src_node_feat (optional): a dict of numpy array as src node features
      dst_node_feat (optional): a dict of numpy array as dst node features
  
      edge_feat (optional): a dict of numpy array as edge features (should
                              have consistent order with edges)
  
  Examples 1:
  
      - Create a graph with numpy.
      - Convert it into paddle.Tensor .
      - Do send recv for graph neural network.
  
      .. code-block:: python
  
          import numpy as np
          import pgl
  
          src_num_nodes = 4
          dst_num_nodes = 5
          edges = [ (0, 1), (1, 2), (3, 4)]
          src_feat = np.random.randn(4, 100).astype(np.float32)
          dst_feat = np.random.randn(5, 100).astype(np.float32)
          edge_feature = np.random.randn(3, 100).astype(np.float32)
          graph = pgl.BiGraph(
                      src_num_nodes=src_num_nodes,
                      dst_num_nodes=dst_num_nodes,
                      edges=edges,
                      src_node_feat={
                          "src_feat": src_feat
                      },
                      dst_node_feat={
                          "dst_feat": dst_feat
                      },
                      edge_feat={
                          "edge_feature": edge_feature
                      })
          graph.tensor() 
  
  Examples 2: 
  
      - Create a graph with paddle.Tensor.
      - Do send recv for graph neural network.
  
      .. code-block:: python
          import numpy as np
          import pgl
  
          src_num_nodes = 4
          dst_num_nodes = 5
          edges = paddle.to_tensor([ (0, 1), (1, 2), (3, 4)])
          src_feat = np.random.randn(4, 100).astype(np.float32)
          src_feat = paddle.to_tensor(src_feat)
          dst_feat = np.random.randn(5, 100).astype(np.float32)
          dst_feat = paddle.to_tensor(dst_feat)
          edge_feature = np.random.randn(3, 100).astype(np.float32)
          edge_feature = paddle.to_tensor(edge_feature)
          graph = pgl.BiGraph(
                      src_num_nodes=src_num_nodes,
                      dst_num_nodes=dst_num_nodes,
                      edges=edges,
                      src_node_feat={
                          "src_feat": src_feat
                      },
                      dst_node_feat={
                          "dst_feat": dst_feat
                      },
                      edge_feat={
                          "edge_feature": edge_feature
                      })
class_docstr_tok: ["Implementation","of","bigraph","interface","in","pgl",".","This","is","a","simple","implementation","of","graph","structure","in","pgl",".","`","pgl.BiGraph","`","is","an","alias","for","`","pgl.graph.BiGraph","`","Args",":","edges",":","list","of","(","u",",","v",")","tuples",",","2D","numpy.ndarry","or","2D","paddle.Tensor","src_num_nodes","(","optional",":","int",",","numpy","or","paddle.Tensor",")",":","Number","of","src_nodes","in","a","bigraph",".","If","not","provided",",","the","number","of","src","nodes","will","be","infered","from","edges","[",":",",","0","]",".","dst_num_nodes","(","optional",":","int",",","numpy","or","paddle.Tensor",")",":","Number","of","dst","nodes","in","a","bigraph",".","If","not","provided",",","the","number","of","dst_nodes","will","be","infered","from","edges","[",":",",","1","]",".","src_node_feat","(","optional",")",":","a","dict","of","numpy","array","as","src","node","features","dst_node_feat","(","optional",")",":","a","dict","of","numpy","array","as","dst","node","features","edge_feat","(","optional",")",":","a","dict","of","numpy","array","as","edge","features","(","should","have","consistent","order","with","edges",")","Examples","1",":","-","Create","a","graph","with","numpy",".","-","Convert","it","into","paddle.Tensor",".","-","Do","send","recv","for","graph","neural","network",".","..","code-block",":",":","python","import","numpy","as","np","import","pgl","src_num_nodes","=","4","dst_num_nodes","=","5","edges","=","[","(","0",",","1",")",",","(","1",",","2",")",",","(","3",",","4",")","]","src_feat","=","np.random.randn","(","4",",","100",")",".astype","(","np.float32",")","dst_feat","=","np.random.randn","(","5",",","100",")",".astype","(","np.float32",")","edge_feature","=","np.random.randn","(","3",",","100",")",".astype","(","np.float32",")","graph","=","pgl.BiGraph","(","src_num_nodes=src_num_nodes",",","dst_num_nodes=dst_num_nodes",",","edges=edges",",","src_node_feat=","{","``","src_feat","''",":","src_feat","}",",","dst_node_feat=","{","``","dst_feat","''",":","dst_feat","}",",","edge_feat=","{","``","edge_feature","''",":","edge_feature","}",")","graph.tensor","(",")","Examples","2",":","-","Create","a","graph","with","paddle.Tensor",".","-","Do","send","recv","for","graph","neural","network",".","..","code-block",":",":","python","import","numpy","as","np","import","pgl","src_num_nodes","=","4","dst_num_nodes","=","5","edges","=","paddle.to_tensor","(","[","(","0",",","1",")",",","(","1",",","2",")",",","(","3",",","4",")","]",")","src_feat","=","np.random.randn","(","4",",","100",")",".astype","(","np.float32",")","src_feat","=","paddle.to_tensor","(","src_feat",")","dst_feat","=","np.random.randn","(","5",",","100",")",".astype","(","np.float32",")","dst_feat","=","paddle.to_tensor","(","dst_feat",")","edge_feature","=","np.random.randn","(","3",",","100",")",".astype","(","np.float32",")","edge_feature","=","paddle.to_tensor","(","edge_feature",")","graph","=","pgl.BiGraph","(","src_num_nodes=src_num_nodes",",","dst_num_nodes=dst_num_nodes",",","edges=edges",",","src_node_feat=","{","``","src_feat","''",":","src_feat","}",",","dst_node_feat=","{","``","dst_feat","''",":","dst_feat","}",",","edge_feat=","{","``","edge_feature","''",":","edge_feature","}",")"]
docstr: This method disjoint list of bigraph into a big bigraph.
  
  Args:
  
      graph_list (BiGraph List): A list of BiGraphs.
  
      merged_graph_index: whether to keeped the graph_id that the nodes belongs to.
  
  
  .. code-block:: python
  
      import numpy as np
      import pgl
  
      src_num_nodes = 4
      dst_num_nodes = 5
      edges = [ (0, 1), (1, 2), (3, 4)]
      src_feat = np.random.randn(4, 100).astype(np.float32)
      dst_feat = np.random.randn(5, 100).astype(np.float32)
      edge_feature = np.random.randn(3, 100).astype(np.float32)
      graph = pgl.BiGraph(
                  src_num_nodes=src_num_nodes,
                  dst_num_nodes=dst_num_nodes,
                  edges=edges,
                  src_node_feat={
                      "src_feat": src_feat
                  },
                  dst_node_feat={
                      "dst_feat": dst_feat
                  },
                  edge_feat={
                      "edge_feature": edge_feature
                  })
      joint_graph = pgl.BiGraph.disjoint([graph, graph], merged_graph_index=False)
      print(joint_graph.dst_graph_node_id)
      >>> [0, 0, 0, 0, 0, 1, 1, 1, 1 ,1]
      print(joint_graph.num_graph)
      >>> 2
  
      joint_graph = pgl.BiGraph.disjoint([graph, graph], merged_graph_index=True)
      print(joint_graph.dst_graph_node_id)
      >>> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
      print(joint_graph.num_graph)
      >>> 1 
docstr_tok: ["This","method","disjoint","list","of","bigraph","into","a","big","bigraph",".","Args",":","graph_list","(","BiGraph","List",")",":","A","list","of","BiGraphs",".","merged_graph_index",":","whether","to","keeped","the","graph_id","that","the","nodes","belongs","to",".","..","code-block",":",":","python","import","numpy","as","np","import","pgl","src_num_nodes","=","4","dst_num_nodes","=","5","edges","=","[","(","0",",","1",")",",","(","1",",","2",")",",","(","3",",","4",")","]","src_feat","=","np.random.randn","(","4",",","100",")",".astype","(","np.float32",")","dst_feat","=","np.random.randn","(","5",",","100",")",".astype","(","np.float32",")","edge_feature","=","np.random.randn","(","3",",","100",")",".astype","(","np.float32",")","graph","=","pgl.BiGraph","(","src_num_nodes=src_num_nodes",",","dst_num_nodes=dst_num_nodes",",","edges=edges",",","src_node_feat=","{","``","src_feat","''",":","src_feat","}",",","dst_node_feat=","{","``","dst_feat","''",":","dst_feat","}",",","edge_feat=","{","``","edge_feature","''",":","edge_feature","}",")","joint_graph","=","pgl.BiGraph.disjoint","(","[","graph",",","graph","]",",","merged_graph_index=False",")","print","(","joint_graph.dst_graph_node_id",")",">",">",">","[","0",",","0",",","0",",","0",",","0",",","1",",","1",",","1",",","1",",1","]","print","(","joint_graph.num_graph",")",">",">",">","2","joint_graph","=","pgl.BiGraph.disjoint","(","[","graph",",","graph","]",",","merged_graph_index=True",")","print","(","joint_graph.dst_graph_node_id",")",">",">",">","[","0",",","0",",","0",",","0",",","0",",","0",",","0",",","0",",","0",",","0","]","print","(","joint_graph.num_graph",")",">",">",">","1"]
code: def disjoint(cls, graph_list, merged_graph_index=False):
      """This method disjoint list of bigraph into a big bigraph.
  
      Args:
  
          graph_list (BiGraph List): A list of BiGraphs.
  
          merged_graph_index: whether to keeped the graph_id that the nodes belongs to.
  
  
      .. code-block:: python
  
          import numpy as np
          import pgl
  
          src_num_nodes = 4
          dst_num_nodes = 5
          edges = [ (0, 1), (1, 2), (3, 4)]
          src_feat = np.random.randn(4, 100).astype(np.float32)
          dst_feat = np.random.randn(5, 100).astype(np.float32)
          edge_feature = np.random.randn(3, 100).astype(np.float32)
          graph = pgl.BiGraph(
                      src_num_nodes=src_num_nodes,
                      dst_num_nodes=dst_num_nodes,
                      edges=edges,
                      src_node_feat={
                          "src_feat": src_feat
                      },
                      dst_node_feat={
                          "dst_feat": dst_feat
                      },
                      edge_feat={
                          "edge_feature": edge_feature
                      })
          joint_graph = pgl.BiGraph.disjoint([graph, graph], merged_graph_index=False)
          print(joint_graph.dst_graph_node_id)
          >>> [0, 0, 0, 0, 0, 1, 1, 1, 1 ,1]
          print(joint_graph.num_graph)
          >>> 2
  
          joint_graph = pgl.BiGraph.disjoint([graph, graph], merged_graph_index=True)
          print(joint_graph.dst_graph_node_id)
          >>> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
          print(joint_graph.num_graph)
          >>> 1
      """
      # TODO:@Yelrose supporting disjoint a disjointed graph_list.
      assert len(graph_list) > 0, (
          "The input graph_list of BiGraph.disjoint has length %s. It should be greater than 0. "
          % len(graph_list)
      )
  
      is_tensor = graph_list[0].is_tensor()
  
      edges = cls._join_edges(graph_list)
      src_num_nodes = cls._join_nodes(graph_list, mode="src_node")
      dst_num_nodes = cls._join_nodes(graph_list, mode="dst_node")
      src_node_feat = cls._join_feature(graph_list, mode="src_node")
      dst_node_feat = cls._join_feature(graph_list, mode="dst_node")
      edge_feat = cls._join_feature(graph_list, mode="edge")
  
      if merged_graph_index is True:
          num_graph = None
          graph_src_node_index = None
          graph_dst_node_index = None
          graph_edge_index = None
      else:
          num_graph = (
              paddle.to_tensor([len(graph_list)], "int64")
              if is_tensor
              else len(graph_list)
          )
          graph_src_node_index = cls._join_graph_index(
              graph_list, mode="src_node"
          )
          graph_dst_node_index = cls._join_graph_index(
              graph_list, mode="dst_node"
          )
          graph_edge_index = cls._join_graph_index(
              graph_list, mode="edge"
          )
  
      graph = cls(
          src_num_nodes=src_num_nodes,
          dst_num_nodes=dst_num_nodes,
          edges=edges,
          src_node_feat=src_node_feat,
          dst_node_feat=dst_node_feat,
          edge_feat=edge_feat,
          _num_graph=num_graph,
          _graph_src_node_index=graph_src_node_index,
          _graph_dst_node_index=graph_dst_node_index,
          _graph_edge_index=graph_edge_index,
      )
      return graph
  
imports: import os
  import json
  import copy
  import warnings
  from collections import defaultdict
  import numpy
  import paddle
  import paddle.distributed
  from pgl.utils import op
  import pgl.graph_kernel
  from pgl.message import Message
  from pgl.utils.edge_index import EdgeIndex
  from pgl.utils.helper import check_is_tensor, maybe_num_nodes
  from pgl.utils.helper import generate_segment_id_from_index, unique_segment
label_desc: Use image node_id 36 for calling the BiGraph obj's underlying member method code with example usage: obj.disjoint(cls, graph_list, merged_graph_index) and returns: graph