class_docstr: Tests for random-walk positional encoding.
class_docstr_tok: ["Tests","for","random-walk","positional","encoding","."]
docstr: Test decalin example.
docstr_tok: ["Test","decalin","example","."]
code: def test_decalin(self):
      """Test decalin example."""
      # Decalin molecule from Fig 4 page 15 from the paper https://arxiv.org/pdf/2110.07875.pdf
      source, target = torch.as_tensor(
          [
              [1, 2, 3, 4, 5, 5, 0, 0, 6, 7, 8],
              [2, 3, 4, 5, 6, 0, 1, 9, 7, 8, 9],
          ]
      )
      # create triples with a dummy relation type 0
      decalin_triples = torch.stack(
          [source, torch.zeros_like(source), target], dim=-1
      )
      templates = torch.as_tensor(
          data=[
              [0.0000, 0.5000, 0.0000, 0.3542, 0.0000],  # green
              [0.0000, 0.4167, 0.0000, 0.2824, 0.0000],  # red
              [0.0000, 0.4444, 0.0000, 0.3179, 0.0000],  # blue
          ],
      )
      # 0: green: 2, 3, 7, 8
      # 1: red: 1, 4, 6, 9
      # 2: blue: 0, 5
      colors = torch.as_tensor(
          data=[2, 1, 0, 0, 1, 2, 1, 0, 0, 1], dtype=torch.long
      )
      rwpe_vectors = templates[colors]
      initializer = pykeen.nn.init.RandomWalkPositionalEncodingInitializer(
          mapped_triples=decalin_triples,
          dim=5,
          # the example includes the first power
          skip_first_power=False,
      )
      assert torch.allclose(
          initializer.tensor, rwpe_vectors, rtol=1.0e-03
      )
  
imports: from typing import ClassVar
  import torch
  from class_resolver import HintOrType
  import pykeen.nn.init
  from pykeen.datasets import Nations
  from pykeen.nn.modules import ComplExInteraction, Interaction, QuatEInteraction
  from tests import cases
  from ..utils import needs_packages
label_desc: Use image node_id 3 for calling the RandomWalkPositionalEncodingInitializerTestCase obj's underlying member method code with example usage: obj.test_decalin() without return types