code: def test_cluster_gcn():
      adj = torch.tensor(
          [
              [1, 1, 1, 0, 1, 0],
              [1, 1, 0, 1, 0, 1],
              [1, 0, 1, 0, 1, 0],
              [0, 1, 0, 1, 0, 1],
              [1, 0, 1, 0, 1, 0],
              [0, 1, 0, 1, 0, 1],
          ]
      )
  
      x = torch.tensor(
          [
              [0.0, 0.0],
              [1.0, 1.0],
              [2.0, 2.0],
              [3.0, 3.0],
              [4.0, 4.0],
              [5.0, 5.0],
          ]
      )
      edge_index = adj.nonzero(as_tuple=False).t()
      edge_attr = torch.arange(edge_index.size(1))
      n_id = torch.arange(6)
      data = Data(
          x=x, n_id=n_id, edge_index=edge_index, edge_attr=edge_attr
      )
      data.num_nodes = 6
  
      cluster_data = ClusterData(data, num_parts=2, log=False)
  
      partition = cluster_data._partition(
          edge_index, cluster=torch.tensor([0, 1, 0, 1, 0, 1])
      )
      assert partition.partptr.tolist() == [0, 3, 6]
      assert partition.node_perm.tolist() == [0, 2, 4, 1, 3, 5]
      assert partition.edge_perm.tolist() == [
          0,
          2,
          3,
          1,
          8,
          9,
          10,
          14,
          15,
          16,
          4,
          5,
          6,
          7,
          11,
          12,
          13,
          17,
          18,
          19,
      ]
  
      assert cluster_data.partition.partptr.tolist() == [0, 3, 6]
      assert torch.equal(
          cluster_data.partition.node_perm.sort()[0],
          torch.arange(data.num_nodes),
      )
      assert torch.equal(
          cluster_data.partition.edge_perm.sort()[0],
          torch.arange(data.num_edges),
      )
  
      out = cluster_data[0]
      expected = data.subgraph(out.n_id)
      out.validate()
      assert out.num_nodes == 3
      assert out.n_id.size() == (3,)
      assert torch.equal(out.x, expected.x)
      tmp = sort_edge_index(expected.edge_index, expected.edge_attr)
      assert torch.equal(out.edge_index, tmp[0])
      assert torch.equal(out.edge_attr, tmp[1])
  
      out = cluster_data[1]
      out.validate()
      assert out.num_nodes == 3
      assert out.n_id.size() == (3,)
      expected = data.subgraph(out.n_id)
      assert torch.equal(out.x, expected.x)
      tmp = sort_edge_index(expected.edge_index, expected.edge_attr)
      assert torch.equal(out.edge_index, tmp[0])
      assert torch.equal(out.edge_attr, tmp[1])
  
      loader = ClusterLoader(cluster_data, batch_size=1)
      iterator = iter(loader)
  
      out = next(iterator)
      out.validate()
      assert out.num_nodes == 3
      assert out.n_id.size() == (3,)
      expected = data.subgraph(out.n_id)
      assert torch.equal(out.x, expected.x)
      tmp = sort_edge_index(expected.edge_index, expected.edge_attr)
      assert torch.equal(out.edge_index, tmp[0])
      assert torch.equal(out.edge_attr, tmp[1])
  
      out = next(iterator)
      out.validate()
      assert out.num_nodes == 3
      assert out.n_id.size() == (3,)
      expected = data.subgraph(out.n_id)
      assert torch.equal(out.x, expected.x)
      tmp = sort_edge_index(expected.edge_index, expected.edge_attr)
      assert torch.equal(out.edge_index, tmp[0])
      assert torch.equal(out.edge_attr, tmp[1])
  
      loader = ClusterLoader(cluster_data, batch_size=2, shuffle=False)
      out = next(iter(loader))
      out.validate()
      assert out.num_nodes == 6
      assert out.n_id.size() == (6,)
      expected = data.subgraph(out.n_id)
      assert torch.equal(out.x, expected.x)
      tmp = sort_edge_index(expected.edge_index, expected.edge_attr)
      assert torch.equal(out.edge_index, tmp[0])
      assert torch.equal(out.edge_attr, tmp[1])
  
file_path: pytorch_geometric/test/loader/test_cluster.py
imports: import pytest
  import torch
  from torch_geometric.data import Data
  from torch_geometric.loader import ClusterData, ClusterLoader
  from torch_geometric.testing import onlyFullTest, onlyOnline
  from torch_geometric.utils import sort_edge_index
label_desc: Use image node_id 1 for calling a global function with example usage: test_cluster_gcn() without return types