code: def to_undirected(graph, copy_node_feat=True, copy_edge_feat=False):
      """Convert a graph to an undirected graph.
  
      Args:
  
          graph (pgl.Graph): The input graph, should be in numpy format.
  
          copy_node_feat (bool): Whether to copy node feature in return graph. Default: True.
  
          copy_edge_feat (bool): [Alternate input] Whether to copy edge feature in return graph.
  
      Returns:
  
          g (pgl.Graph): Returns an undirected graph.
  
      """
  
      if graph.is_tensor():
          raise TypeError("The input graph should be numpy format.")
  
      inv_edges = np.zeros(graph.edges.shape)
      inv_edges[:, 0] = graph.edges[:, 1]
      inv_edges[:, 1] = graph.edges[:, 0]
      edges = np.vstack((graph.edges, inv_edges))
      edges = np.unique(edges, axis=0)
      g = pgl.graph.Graph(num_nodes=graph.num_nodes, edges=edges)
  
      if copy_node_feat:
          for k, v in graph._node_feat.items():
              g._node_feat[k] = v
  
      if copy_edge_feat:
          # TODO(daisiming): Support duplicate edge_feature.
          raise NotImplementedError(
              "The copy of edge feature is not implemented currently."
          )
  
      return g
  
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 1 for calling a global function with example usage: to_undirected(graph, copy_node_feat, copy_edge_feat) and returns: g