code: def assert_correct(row, col, cluster):
      row, col, cluster = (
          row.to("cpu"),
          col.to("cpu"),
          cluster.to("cpu"),
      )
      n = cluster.size(0)
  
      # Every node was assigned a cluster.
      assert cluster.min() >= 0
  
      # There are no more than two nodes in each cluster.
      _, index = torch.unique(cluster, return_inverse=True)
      count = torch.zeros_like(cluster)
      count.scatter_add_(0, index, torch.ones_like(cluster))
      assert (count > 2).max() == 0
  
      # Cluster value is minimal.
      assert (
          cluster <= torch.arange(n, dtype=cluster.dtype)
      ).sum() == n
  
      # Corresponding clusters must be adjacent.
      for i in range(n):
          x = (
              cluster[col[row == i]] == cluster[i]
          )  # Neighbors with same cluster
          y = cluster == cluster[i]  # Nodes with same cluster.
          y[i] = 0  # Do not look at cluster of `i`.
          assert x.sum() == y.sum()
  
imports: from itertools import product
  import pytest
  import torch
  from torch_cluster import graclus_cluster
  from torch_cluster.testing import devices, dtypes, tensor
label_desc: Use image node_id 1 for calling a global function with example usage: assert_correct(row, col, cluster) without return types