class_docstr: Tests for :mod:`pykeen.utils`.
class_docstr_tok: ["Tests","for",":","mod",":","`","pykeen.utils","`","."]
docstr: Test ``estimate_cost_of_add_sequence()``.
docstr_tok: ["Test","``","estimate_cost_of_add_sequence","(",")","``","."]
code: def test_estimate_cost_of_add_sequence(self):
      """Test ``estimate_cost_of_add_sequence()``."""
      _, generator, _ = set_random_seed(seed=42)
      # create random array, estimate the costs of addition, and measure some execution times.
      # then, compute correlation between the estimated cost, and the measured time.
      data = []
      for shapes in _generate_shapes(generator=generator):
          arrays = [torch.empty(*shape) for shape in shapes]
          cost = estimate_cost_of_sequence(*(a.shape for a in arrays))
          n_samples, time = timeit.Timer(
              stmt="sum(arrays)", globals=dict(arrays=arrays)
          ).autorange()
          consumption = time / n_samples
          data.append((cost, consumption))
      a = numpy.asarray(data)
  
      # check for strong correlation between estimated costs and measured execution time
      assert (numpy.corrcoef(x=a[:, 0], y=a[:, 1])[0, 1]) > 0.8
  
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 6 for calling the TestUtils obj's underlying member method code with example usage: obj.test_estimate_cost_of_add_sequence() without return types