code: def between_two_vectors_3d(
      vector1: type_alias.TensorLike,
      vector2: type_alias.TensorLike,
      name: str = "quaternion_between_two_vectors_3d",
  ) -> tf.Tensor:
      """Computes quaternion over the shortest arc between two vectors.
  
      Result quaternion describes shortest geodesic rotation from
      vector1 to vector2.
  
      Note:
        In the following, A1 to An are optional batch dimensions.
  
      Args:
        vector1: A tensor of shape `[A1, ..., An, 3]`, where the last dimension
          represents the first vector.
        vector2: A tensor of shape `[A1, ..., An, 3]`, where the last dimension
          represents the second vector.
        name: A name for this op that defaults to
          "quaternion_between_two_vectors_3d".
  
      Returns:
        A tensor of shape `[A1, ..., An, 4]`, where the last dimension represents
        a normalized quaternion.
  
      Raises:
        ValueError: If the shape of `vector1` or `vector2` is not supported.
      """
      with tf.name_scope(name):
          vector1 = tf.convert_to_tensor(value=vector1)
          vector2 = tf.convert_to_tensor(value=vector2)
  
          shape.check_static(
              tensor=vector1,
              tensor_name="vector1",
              has_dim_equals=(-1, 3),
          )
          shape.check_static(
              tensor=vector2,
              tensor_name="vector2",
              has_dim_equals=(-1, 3),
          )
          shape.compare_batch_dimensions(
              tensors=(vector1, vector2),
              last_axes=-2,
              broadcast_compatible=True,
          )
  
          # Make sure that we are dealing with unit vectors.
          vector1 = tf.nn.l2_normalize(vector1, axis=-1)
          vector2 = tf.nn.l2_normalize(vector2, axis=-1)
          cos_theta = vector.dot(vector1, vector2)
          real_part = 1.0 + cos_theta
          axis = vector.cross(vector1, vector2)
  
          # Compute arbitrary antiparallel axes to rotate around in case of opposite
          # vectors.
          x, y, z = tf.split(vector1, (1, 1, 1), axis=-1)
          x_bigger_z = tf.abs(x) > tf.abs(z)
          x_bigger_z = tf.concat([x_bigger_z] * 3, axis=-1)
          antiparallel_axis = tf.where(
              x_bigger_z,
              tf.concat((-y, x, tf.zeros_like(z)), axis=-1),
              tf.concat((tf.zeros_like(x), -z, y), axis=-1),
          )
  
          # Compute rotation between two vectors.
          is_antiparallel = real_part < 1e-6
          is_antiparallel = tf.concat([is_antiparallel] * 4, axis=-1)
          rot = tf.where(
              is_antiparallel,
              tf.concat(
                  (antiparallel_axis, tf.zeros_like(real_part)), axis=-1
              ),
              tf.concat((axis, real_part), axis=-1),
          )
          return tf.nn.l2_normalize(rot, axis=-1)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import List
  from six.moves import range
  import tensorflow
  from tensorflow_graphics.geometry.transformation import rotation_matrix_3d
  from tensorflow_graphics.math import vector
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import export_api
  from tensorflow_graphics.util import safe_ops
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 2 for calling a global function with example usage: between_two_vectors_3d(vector1, vector2, name) and returns: tf