class_docstr: Tests for the vectorized computation of KL divergences.
class_docstr_tok: ["Tests","for","the","vectorized","computation","of","KL","divergences","."]
code: def setUp(self) -> None:  # noqa: D102
      dims = dict(
          h=self.num_heads, r=self.num_relations, t=self.num_tails
      )
      (self.h_mean, self.r_mean, self.t_mean), (
          self.h_var,
          self.r_var,
          self.t_var,
      ) = [
          [
              # TODO this is the only place this function is used.
              #  Is there an alternative so we can remove it?
              convert_to_canonical_shape(
                  x=torch.rand(self.batch_size, num, self.d),
                  dim=dim,
                  num=num,
                  batch_size=self.batch_size,
              )
              for dim, num in dims.items()
          ]
          for _ in ("mean", "diagonal_covariance")
      ]
      # ensure positivity
      self.h_var, self.r_var, self.t_var = [
          x.exp() for x in (self.h_var, self.r_var, self.t_var)
      ]
  
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 1 for calling the KullbackLeiblerTests obj's underlying member method code with example usage: obj.setUp() without return types