class_docstr: Tests for :mod:`pykeen.utils`.
class_docstr_tok: ["Tests","for",":","mod",":","`","pykeen.utils","`","."]
docstr: Test Weisfeiler Lehman.
docstr_tok: ["Test","Weisfeiler","Lehman","."]
code: def test_weisfeiler_lehman(self):
      """Test Weisfeiler Lehman."""
      _, generator, _ = set_random_seed(seed=42)
      num_nodes = 13
      num_edges = 31
      max_iter = 3
      edge_index = torch.randint(
          num_nodes, size=(2, num_edges), generator=generator
      )
      # ensure each node participates in at least one edge
      edge_index[0, :num_nodes] = torch.arange(num_nodes)
  
      count = 0
      color_count = 0
      for colors in iter_weisfeiler_lehman(
          edge_index=edge_index, max_iter=max_iter
      ):
          # check type and shape
          assert torch.is_tensor(colors)
          assert colors.shape == (num_nodes,)
          assert colors.dtype == torch.long
          # number of colors is monotonically increasing
          num_unique_colors = len(colors.unique())
          assert num_unique_colors >= color_count
          color_count = num_unique_colors
          count += 1
      assert count == max_iter
  
imports: import functools
  import itertools
  import operator
  import random
  import string
  import timeit
  import unittest
  from typing import Iterable, Tuple
  import numpy
  import pytest
  import torch
  from pykeen.utils import _weisfeiler_lehman_iteration, _weisfeiler_lehman_iteration_approx, calculate_broadcasted_elementwise_result_shape, clamp_norm, combine_complex, compact_mapping, compose, estimate_cost_of_sequence, flatten_dictionary, get_optimal_sequence, get_until_first_blank, iter_weisfeiler_lehman, logcumsumexp, project_entity, set_random_seed, split_complex, tensor_product, tensor_sum
label_desc: Use image node_id 12 for calling the TestUtils obj's underlying member method code with example usage: obj.test_weisfeiler_lehman() without return types