class_docstr: Tests for the vectorized computation of KL divergences.
class_docstr_tok: ["Tests","for","the","vectorized","computation","of","KL","divergences","."]
docstr: Check value of similarity to self.
docstr_tok: ["Check","value","of","similarity","to","self","."]
code: def test_self_similarity(self):
      """Check value of similarity to self."""
      # e: (batch_size, num_heads, num_tails, d)
      # https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence#Properties
      # divergence = 0 => similarity = -divergence = 0
      # (h - t), r
      r = self._get(name="r")
      h = GaussianDistribution(
          mean=2 * r.mean,
          diagonal_covariance=0.5 * r.diagonal_covariance,
      )
      t = GaussianDistribution(
          mean=r.mean, diagonal_covariance=0.5 * r.diagonal_covariance
      )
      sim = kullback_leibler_similarity(h=h, r=r, t=t, exact=True)
      self.assertTrue(
          torch.allclose(sim, torch.zeros_like(sim)), msg=f"Sim: {sim}"
      )
  
file_path: pykeen/tests/test_nn/test_sim.py
imports: import itertools
  import unittest
  import torch
  from pykeen.nn.sim import _torch_kl_similarity, kullback_leibler_similarity
  from pykeen.typing import GaussianDistribution
  from pykeen.utils import convert_to_canonical_shape
label_desc: Use image node_id 5 for calling the KullbackLeiblerTests obj's underlying member method code with example usage: obj.test_self_similarity() without return types