code: def _zyz_to_quat(angles):
      """Converts a set of Euler angles in ZYZ format to a quaternion."""
      qw = cos(angles[1] / 2) * cos(0.5 * (angles[0] + angles[2]))
      qx = -sin(angles[1] / 2) * sin(0.5 * (angles[0] - angles[2]))
      qy = sin(angles[1] / 2) * cos(0.5 * (angles[0] - angles[2]))
      qz = cos(angles[1] / 2) * sin(0.5 * (angles[0] + angles[2]))
  
      return stack([qw, qx, qy, qz])
  
file_path: pennylane/pennylane/transforms/optimization/optimization_utils.py
imports: from functools import partial
  import numpy
  from pennylane.math import abs
  from pennylane.math import sum
  from pennylane.math import allclose, arccos, arctan2, cos, get_interface, is_abstract, sin, stack
  from pennylane.wires import Wires
  from pennylane.ops.identity import GlobalPhase
label_desc: Use image node_id 2 for calling a global function with example usage: _zyz_to_quat(angles) and returns: stack