code: def normalize_quaternion(
      quaternion: Tensor, eps: float = 1.0e-12
  ) -> Tensor:
      r"""Normalize a quaternion.
  
      The quaternion should be in (x, y, z, w) or (w, x, y, z) format.
  
      Args:
          quaternion: a tensor containing a quaternion to be normalized.
            The tensor can be of shape :math:`(*, 4)`.
          eps: small value to avoid division by zero.
  
      Return:
          the normalized quaternion of shape :math:`(*, 4)`.
  
      Example:
          >>> quaternion = tensor((1., 0., 1., 0.))
          >>> normalize_quaternion(quaternion)
          tensor([0.7071, 0.0000, 0.7071, 0.0000])
      """
      if not isinstance(quaternion, Tensor):
          raise TypeError(
              f"Input type is not a Tensor. Got {type(quaternion)}"
          )
  
      if not quaternion.shape[-1] == 4:
          raise ValueError(
              f"Input must be a tensor of shape (*, 4). Got {quaternion.shape}"
          )
      return F.normalize(quaternion, p=2.0, dim=-1, eps=eps)
  
imports: from __future__ import annotations
  from typing import Optional
  import torch
  import torch.nn.functional
  from kornia.constants import pi
  from kornia.core import Tensor, concatenate, cos, pad, sin, stack, tensor, where, zeros_like
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_SHAPE
  from kornia.utils import deprecated
  from kornia.utils.helpers import _torch_inverse_cast
label_desc: Use image node_id 15 for calling a global function with example usage: normalize_quaternion(quaternion, eps) and returns: F