code: def quaternion_normalizer(x: torch.FloatTensor) -> torch.FloatTensor:
      r"""
      Normalize the length of relation vectors, if the forward constraint has not been applied yet.
  
      Absolute value of a quaternion
  
      .. math::
  
          |a + bi + cj + dk| = \sqrt{a^2 + b^2 + c^2 + d^2}
  
      L2 norm of quaternion vector:
  
      .. math::
          \|x\|^2 = \sum_{i=1}^d |x_i|^2
                   = \sum_{i=1}^d (x_i.re^2 + x_i.im_1^2 + x_i.im_2^2 + x_i.im_3^2)
      :param x:
          The vector.
  
      :return:
          The normalized vector.
      """
      # Normalize relation embeddings
      shape = x.shape
      x = x.view(*shape[:-1], -1, 4)
      x = functional.normalize(x, p=2, dim=-1)
      return x.view(*shape)
  
file_path: pykeen/src/pykeen/models/unimodal/quate.py
imports: from typing import Any, ClassVar, Mapping, Optional, Type
  import torch
  from torch.nn import functional
  from ..nbase import ERModel
  from ...constants import DEFAULT_EMBEDDING_HPO_EMBEDDING_DIM_RANGE
  from ...losses import BCEWithLogitsLoss, Loss
  from ...nn.init import init_quaternions
  from ...nn.modules import QuatEInteraction
  from ...regularizers import LpRegularizer, Regularizer
  from ...typing import Constrainer, Hint, Initializer
  from ...utils import get_expected_norm
label_desc: Use image node_id 1 for calling a global function with example usage: quaternion_normalizer(x) and returns: x