code: def test_to_undirected():
      assert str(ToUndirected()) == "ToUndirected()"
  
      edge_index = torch.tensor([[2, 0, 2], [3, 1, 0]])
      edge_weight = torch.randn(edge_index.size(1))
      edge_attr = torch.randn(edge_index.size(1), 8)
  
      perm = torch.tensor([1, 2, 1, 2, 0, 0])
  
      data = Data(
          edge_index=edge_index,
          edge_weight=edge_weight,
          edge_attr=edge_attr,
          num_nodes=4,
      )
      data = ToUndirected()(data)
      assert len(data) == 4
      assert data.edge_index.tolist() == [
          [0, 0, 1, 2, 2, 3],
          [1, 2, 0, 0, 3, 2],
      ]
      assert data.edge_weight.tolist() == edge_weight[perm].tolist()
      assert data.edge_attr.tolist() == edge_attr[perm].tolist()
      assert data.num_nodes == 4
  
imports: import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.transforms import ToUndirected
label_desc: Use image node_id 1 for calling a global function with example usage: test_to_undirected() without return types