code: def _convert_to_su2(U):
      r"""Convert a 2x2 unitary matrix to :math:`SU(2)`.
  
      Args:
          U (array[complex]): A matrix, presumed to be :math:`2 \times 2` and unitary.
          return_global_phase (bool): If `True`, the return will include
          the global phase. If `False`, only the :math:`SU(2)` representative
          is returned.
  
      Returns:
          array[complex]: A :math:`2 \times 2` matrix in :math:`SU(2)` that is
          equivalent to U up to a global phase. If ``return_global_phase=True``,
          a 2-element tuple is returned, with the first element being the
          :math:`SU(2)` equivalent and the second, the global phase.
      """
      # Compute the determinants
      dets = math.linalg.det(U)
  
      exp_angles = math.cast_like(math.angle(dets), 1j) / 2
      U_SU2 = math.cast_like(U, dets) * math.exp(-1j * exp_angles)
      return U_SU2
  
file_path: pennylane/pennylane/ops/op_math/controlled_decompositions.py
imports: from copy import copy
  import numpy
  import numpy.linalg
  import pennylane
  from pennylane.operation import Operator
  from pennylane.wires import Wires
  from pennylane import math
label_desc: Use image node_id 1 for calling a global function with example usage: _convert_to_su2(U) and returns: U_SU2