code: def test_to_networkx():
      import networkx as nx
  
      x = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
      pos = torch.tensor([[0.0, 0.0], [1.0, 1.0]])
      edge_index = torch.tensor([[0, 1, 0], [1, 0, 0]])
      edge_attr = torch.tensor([1.0, 2.0, 3.0])
      data = Data(x=x, pos=pos, edge_index=edge_index, weight=edge_attr)
  
      for remove_self_loops in [True, False]:
          G = to_networkx(
              data,
              node_attrs=["x", "pos"],
              edge_attrs=["weight"],
              remove_self_loops=remove_self_loops,
          )
  
          assert G.nodes[0]["x"] == [1.0, 2.0]
          assert G.nodes[1]["x"] == [3.0, 4.0]
          assert G.nodes[0]["pos"] == [0.0, 0.0]
          assert G.nodes[1]["pos"] == [1.0, 1.0]
  
          if remove_self_loops:
              assert nx.to_numpy_array(G).tolist() == [
                  [0.0, 1.0],
                  [2.0, 0.0],
              ]
          else:
              assert nx.to_numpy_array(G).tolist() == [
                  [3.0, 1.0],
                  [2.0, 0.0],
              ]
  
imports: import pytest
  import scipy.sparse
  import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.testing import get_random_edge_index, withPackage
  from torch_geometric.utils import from_cugraph, from_dgl, from_networkit, from_networkx, from_scipy_sparse_matrix, from_trimesh, sort_edge_index, subgraph, to_cugraph, to_dgl, to_networkit, to_networkx, to_scipy_sparse_matrix, to_trimesh
label_desc: Use image node_id 3 for calling a global function with example usage: test_to_networkx() without return types