code: def log(q, eps=1e-8):
      """Computes the quaternion logarithm.
  
      References:
        https://en.wikipedia.org/wiki/Quaternion#Exponential,_logarithm,_and_power_functions
  
      Args:
        q: the quaternion in (x,y,z,w) format.
        eps: an epsilon value for numerical stability.
  
      Returns:
        The logarithm of q.
      """
      mag = linalg.norm(q, axis=-1, keepdims=True)
      v = im(q)
      s = re(q)
      w = jnp.log(mag)
      denom = jnp.maximum(
          linalg.norm(v, axis=-1, keepdims=True), eps * jnp.ones_like(v)
      )
      xyz = v / denom * safe_acos(s / eps)
      return jnp.concatenate((xyz, w), axis=-1)
  
file_path: nerfies/nerfies/quaternion.py
imports: from jax import numpy
  from jax.numpy import linalg
label_desc: Use image node_id 11 for calling a global function with example usage: log(q, eps) and returns: jnp