code: def quaternion_apply(
      quaternion: torch.Tensor, point: torch.Tensor
  ) -> torch.Tensor:
      """
      Apply the rotation given by a quaternion to a 3D point.
      Usual torch rules for broadcasting apply.
  
      Args:
          quaternion: Tensor of quaternions, real part first, of shape (..., 4).
          point: Tensor of 3D points of shape (..., 3).
  
      Returns:
          Tensor of rotated points of shape (..., 3).
      """
      if point.size(-1) != 3:
          raise ValueError(f"Points are not in 3D, {point.shape}.")
      real_parts = point.new_zeros(point.shape[:-1] + (1,))
      point_as_quaternion = torch.cat((real_parts, point), -1)
      out = quaternion_raw_multiply(
          quaternion_raw_multiply(quaternion, point_as_quaternion),
          quaternion_invert(quaternion),
      )
      return out[..., 1:]
  
imports: from typing import Optional
  import torch
  import torch.nn.functional
  from ..common.datatypes import Device
label_desc: Use image node_id 17 for calling a global function with example usage: quaternion_apply(quaternion, point) and returns: out