def quaternion_exp_to_log(quaternion: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
    'Applies the log map to 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          converted. The tensor can be of shape :math:`(*, 4)`.\n\n    Return:\n        torch.Tensor: the quaternion log map of shape :math:`(*, 3)`.\n\n    Example:\n        >>> quaternion = torch.tensor([0., 0., 0., 1.])\n        >>> quaternion_exp_to_log(quaternion)\n        tensor([0., 0., 0.])\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))
    quaternion_vector: torch.Tensor = quaternion[..., 0:3]
    quaternion_scalar: torch.Tensor = quaternion[..., 3:4]
    norm_q: torch.Tensor = torch.norm(quaternion_vector, p=2, dim=(- 1), keepdim=True).clamp(min=eps)
    quaternion_log: torch.Tensor = ((quaternion_vector * torch.acos(torch.clamp(quaternion_scalar, min=(- 1.0), max=1.0))) / norm_q)
    return quaternion_log
Applies the log map to a quaternion.
The quaternion should be in (x, y, z, w) format.

Args:
    quaternion (torch.Tensor): a tensor containing a quaternion to be
      converted. The tensor can be of shape :math:`(*, 4)`.

Return:
    torch.Tensor: the quaternion log map of shape :math:`(*, 3)`.

Example:
    >>> quaternion = torch.tensor([0., 0., 0., 1.])
    >>> quaternion_exp_to_log(quaternion)
    tensor([0., 0., 0.])
def quaternion_exp_to_log(quaternion: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
    'Applies the log map to 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          converted. The tensor can be of shape :math:`(*, 4)`.\n\n    Return:\n        torch.Tensor: the quaternion log map of shape :math:`(*, 3)`.\n\n    Example:\n        >>> quaternion = torch.tensor([0., 0., 0., 1.])\n        >>> quaternion_exp_to_log(quaternion)\n        tensor([0., 0., 0.])\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))
    quaternion_vector: torch.Tensor = quaternion[..., 0:3]
    quaternion_scalar: torch.Tensor = quaternion[..., 3:4]
    norm_q: torch.Tensor = torch.norm(quaternion_vector, p=2, dim=(- 1), keepdim=True).clamp(min=eps)
    quaternion_log: torch.Tensor = ((quaternion_vector * torch.acos(torch.clamp(quaternion_scalar, min=(- 1.0), max=1.0))) / norm_q)
    return quaternion_log