class_docstr: Test an L_2 normed regularizer.
docstr: Numerically check expected norm.
docstr_tok: ["Numerically","check","expected","norm","."]
code: def test_expected_norm(self):
      """Numerically check expected norm."""
      n = 100
      for p in (1, 2, 3):
          for d in (2, 8, 64):
              e_norm = get_expected_norm(p=p, d=d)
              norm = torch.randn(n, d).norm(p=p, dim=-1).numpy()
              norm_mean = norm.mean()
              norm_std = norm.std()
              # check if within 0.5 std of observed
              assert (abs(norm_mean - e_norm) / norm_std) < 0.5
  
      # test error is raised
      with pytest.raises(NotImplementedError):
          get_expected_norm(p=float("inf"), d=d)
  
imports: import unittest
  from typing import Sequence
  import pytest
  import torch
  import unittest_templates
  from torch.nn import functional
  import pykeen.regularizers
  from pykeen.utils import get_expected_norm
  from tests import cases
  from tests.utils import rand
label_desc: Use image node_id 1 for calling the NormedL2RegularizerTest obj's underlying member method code with example usage: obj.test_expected_norm() without return types