def normalize_quaternion(quaternion: torch.Tensor, eps: float=1e-12) -> torch.Tensor:
    'Normalizes a quaternion.\n    The quaternion should be in (x, y, z, w) format.\n\n    Args:\n        quaternion (torch.Tensor): a tensor containing a quaternion to be\n          normalized. The tensor can be of shape :math:`(*, 4)`.\n        eps (Optional[bool]): small value to avoid division by zero.\n          Default: 1e-12.\n\n    Return:\n        torch.Tensor: the normalized quaternion of shape :math:`(*, 4)`.\n\n    Example:\n        >>> quaternion = torch.tensor([1., 0., 1., 0.])\n        >>> normalize_quaternion(quaternion)\n        tensor([0.7071, 0.0000, 0.7071, 0.0000])\n    '
    if (not isinstance(quaternion, torch.Tensor)):
        raise TypeError('Input type is not a torch.Tensor. Got {}'.format(type(quaternion)))
    if (not (quaternion.shape[(- 1)] == 4)):
        raise ValueError('Input must be a tensor of shape (*, 4). Got {}'.format(quaternion.shape))
    return F.normalize(quaternion, p=2, dim=(- 1), eps=eps)
Normalizes a quaternion.
The quaternion should be in (x, y, z, w) format.

Args:
    quaternion (torch.Tensor): a tensor containing a quaternion to be
      normalized. The tensor can be of shape :math:`(*, 4)`.
    eps (Optional[bool]): small value to avoid division by zero.
      Default: 1e-12.

Return:
    torch.Tensor: the normalized quaternion of shape :math:`(*, 4)`.

Example:
    >>> quaternion = torch.tensor([1., 0., 1., 0.])
    >>> normalize_quaternion(quaternion)
    tensor([0.7071, 0.0000, 0.7071, 0.0000])
def normalize_quaternion(quaternion: torch.Tensor, eps: float=1e-12) -> torch.Tensor:
    'Normalizes a quaternion.\n    The quaternion should be in (x, y, z, w) format.\n\n    Args:\n        quaternion (torch.Tensor): a tensor containing a quaternion to be\n          normalized. The tensor can be of shape :math:`(*, 4)`.\n        eps (Optional[bool]): small value to avoid division by zero.\n          Default: 1e-12.\n\n    Return:\n        torch.Tensor: the normalized quaternion of shape :math:`(*, 4)`.\n\n    Example:\n        >>> quaternion = torch.tensor([1., 0., 1., 0.])\n        >>> normalize_quaternion(quaternion)\n        tensor([0.7071, 0.0000, 0.7071, 0.0000])\n    '
    if (not isinstance(quaternion, torch.Tensor)):
        raise TypeError('Input type is not a torch.Tensor. Got {}'.format(type(quaternion)))
    if (not (quaternion.shape[(- 1)] == 4)):
        raise ValueError('Input must be a tensor of shape (*, 4). Got {}'.format(quaternion.shape))
    return F.normalize(quaternion, p=2, dim=(- 1), eps=eps)