class_docstr: Test the norm-limit regularizer.
code: def _expected_penalty(
      self, x: torch.FloatTensor
  ) -> torch.FloatTensor:  # noqa: D102
      kwargs = self.instance_kwargs
      p = kwargs.get("p", 2.0)
      power_norm = kwargs.get("power_norm", True)
      if power_norm:
          value = x.pow(p).sum(dim=-1)
      else:
          value = x.norm(p=p, dim=-1)
      max_norm = kwargs.get("max_norm", 1.0)
      return (value - max_norm).relu().sum()
  
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 NormLimitRegularizerTest obj's underlying member method code with example usage: obj._expected_penalty(x) and returns: unknown