code: def quaternion_to_axis_angle(quaternion: Tensor) -> Tensor:
      """Convert quaternion vector to axis angle of rotation in radians.
  
      The quaternion should be in (w, x, y, z) format.
  
      Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h
  
      Args:
          quaternion: tensor with quaternions.
  
      Return:
          tensor with axis angle of rotation.
  
      Shape:
          - Input: :math:`(*, 4)` where `*` means, any number of dimensions
          - Output: :math:`(*, 3)`
  
      Example:
          >>> quaternion = tensor((1., 0., 0., 0.))
          >>> quaternion_to_axis_angle(quaternion)
          tensor([0., 0., 0.])
      """
      if not torch.is_tensor(quaternion):
          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 Nx4 or 4. Got {quaternion.shape}"
          )
  
      # unpack input and compute conversion
      q1: Tensor = tensor([])
      q2: Tensor = tensor([])
      q3: Tensor = tensor([])
      cos_theta: Tensor = tensor([])
  
      cos_theta = quaternion[..., 0]
      q1 = quaternion[..., 1]
      q2 = quaternion[..., 2]
      q3 = quaternion[..., 3]
  
      sin_squared_theta: Tensor = q1 * q1 + q2 * q2 + q3 * q3
  
      sin_theta: Tensor = torch.sqrt(sin_squared_theta)
      two_theta: Tensor = 2.0 * where(
          cos_theta < 0.0,
          torch.atan2(-sin_theta, -cos_theta),
          torch.atan2(sin_theta, cos_theta),
      )
  
      k_pos: Tensor = two_theta / sin_theta
      k_neg: Tensor = 2.0 * torch.ones_like(sin_theta)
      k: Tensor = where(sin_squared_theta > 0.0, k_pos, k_neg)
  
      axis_angle: Tensor = torch.zeros_like(quaternion)[..., :3]
      axis_angle[..., 0] += q1 * k
      axis_angle[..., 1] += q2 * k
      axis_angle[..., 2] += q3 * k
      return axis_angle
  
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 17 for calling a global function with example usage: quaternion_to_axis_angle(quaternion) and returns: axis_angle