class_docstr: QubitUnitary(U, wires)
  Apply an arbitrary unitary matrix with a dimension that is a power of two.
  
  **Details:**
  
  * Number of wires: Any (the operation can act on any number of wires)
  * Number of parameters: 1
  * Number of dimensions per parameter: (2,)
  * Gradient recipe: None
  
  Args:
      U (array[complex]): square unitary matrix
      wires (Sequence[int] or int): the wire(s) the operation acts on
      id (str): custom label given to an operator instance,
          can be useful for some applications where the instance has to be identified
      unitary_check (bool): check for unitarity of the given matrix
  
  Raises:
      ValueError: if the number of wires doesn't fit the dimensions of the matrix
  
  **Example**
  
  >>> dev = qml.device('default.qubit', wires=1)
  >>> U = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])
  >>> @qml.qnode(dev)
  ... def example_circuit():
  ...     qml.QubitUnitary(U, wires=0)
  ...     return qml.expval(qml.PauliZ(0))
  >>> print(example_circuit())
  0.0
class_docstr_tok: ["QubitUnitary","(","U",",","wires",")","Apply","an","arbitrary","unitary","matrix","with","a","dimension","that","is","a","power","of","two",".","*","*","Details",":","*","*","*","Number","of","wires",":","Any","(","the","operation","can","act","on","any","number","of","wires",")","*","Number","of","parameters",":","1","*","Number","of","dimensions","per","parameter",":","(","2",",",")","*","Gradient","recipe",":","None","Args",":","U","(","array","[","complex","]",")",":","square","unitary","matrix","wires","(","Sequence","[","int","]","or","int",")",":","the","wire","(","s",")","the","operation","acts","on","id","(","str",")",":","custom","label","given","to","an","operator","instance",",","can","be","useful","for","some","applications","where","the","instance","has","to","be","identified","unitary_check","(","bool",")",":","check","for","unitarity","of","the","given","matrix","Raises",":","ValueError",":","if","the","number","of","wires","does","n't","fit","the","dimensions","of","the","matrix","*","*","Example","*","*",">",">",">","dev","=","qml.device","(","'default.qubit","'",",","wires=1",")",">",">",">","U","=","1","\/","np.sqrt","(","2",")","*","np.array","(","[","[","1",",","1","]",",","[","1",",","-1","]","]",")",">",">",">","@","qml.qnode","(","dev",")","...","def","example_circuit","(",")",":","...","qml.QubitUnitary","(","U",",","wires=0",")","...","return","qml.expval","(","qml.PauliZ","(","0",")",")",">",">",">","print","(","example_circuit","(",")",")","0.0"]
docstr: Representation of the operator as a product of other operators (static method).
  
  .. math:: O = O_1 O_2 \dots O_n.
  
  A decomposition is only defined for matrices that act on either one or two wires. For more
  than two wires, this method raises a ``DecompositionUndefined``.
  
  See :func:`~.transforms.one_qubit_decomposition` and :func:`~.ops.two_qubit_decomposition`
  for more information on how the decompositions are computed.
  
  .. seealso:: :meth:`~.QubitUnitary.decomposition`.
  
  Args:
      U (array[complex]): square unitary matrix
      wires (Iterable[Any] or Wires): the wire(s) the operation acts on
  
  Returns:
      list[Operator]: decomposition of the operator
  
  **Example:**
  
  >>> U = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])
  >>> qml.QubitUnitary.compute_decomposition(U, 0)
  [Rot(tensor(3.14159265, requires_grad=True), tensor(1.57079633, requires_grad=True), tensor(0., requires_grad=True), wires=[0])]
docstr_tok: ["Representation","of","the","operator","as","a","product","of","other","operators","(","static","method",")",".","..","math",":",":","O","=","O_1","O_2","\\dots","O_n",".","A","decomposition","is","only","defined","for","matrices","that","act","on","either","one","or","two","wires",".","For","more","than","two","wires",",","this","method","raises","a","``","DecompositionUndefined","``",".","See",":","func",":","`","~.transforms.one_qubit_decomposition","`","and",":","func",":","`","~.ops.two_qubit_decomposition","`","for","more","information","on","how","the","decompositions","are","computed",".","..","seealso",":",":",":","meth",":","`","~.QubitUnitary.decomposition","`",".","Args",":","U","(","array","[","complex","]",")",":","square","unitary","matrix","wires","(","Iterable","[","Any","]","or","Wires",")",":","the","wire","(","s",")","the","operation","acts","on","Returns",":","list","[","Operator","]",":","decomposition","of","the","operator","*","*","Example",":","*","*",">",">",">","U","=","1","\/","np.sqrt","(","2",")","*","np.array","(","[","[","1",",","1","]",",","[","1",",","-1","]","]",")",">",">",">","qml.QubitUnitary.compute_decomposition","(","U",",","0",")","[","Rot","(","tensor","(","3.14159265",",","requires_grad=True",")",",","tensor","(","1.57079633",",","requires_grad=True",")",",","tensor","(","0.",",","requires_grad=True",")",",","wires=","[","0","]",")","]"]
code: def compute_decomposition(U, wires):
      r"""Representation of the operator as a product of other operators (static method).
  
      .. math:: O = O_1 O_2 \dots O_n.
  
      A decomposition is only defined for matrices that act on either one or two wires. For more
      than two wires, this method raises a ``DecompositionUndefined``.
  
      See :func:`~.transforms.one_qubit_decomposition` and :func:`~.ops.two_qubit_decomposition`
      for more information on how the decompositions are computed.
  
      .. seealso:: :meth:`~.QubitUnitary.decomposition`.
  
      Args:
          U (array[complex]): square unitary matrix
          wires (Iterable[Any] or Wires): the wire(s) the operation acts on
  
      Returns:
          list[Operator]: decomposition of the operator
  
      **Example:**
  
      >>> U = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])
      >>> qml.QubitUnitary.compute_decomposition(U, 0)
      [Rot(tensor(3.14159265, requires_grad=True), tensor(1.57079633, requires_grad=True), tensor(0., requires_grad=True), wires=[0])]
  
      """
      # Decomposes arbitrary single-qubit unitaries as Rot gates (RZ - RY - RZ format),
      # or a single RZ for diagonal matrices.
      shape = qml.math.shape(U)
  
      is_batched = len(shape) == 3
      shape_without_batch_dim = shape[1:] if is_batched else shape
  
      if shape_without_batch_dim == (2, 2):
          return qml.ops.one_qubit_decomposition(U, Wires(wires)[0])
  
      if shape_without_batch_dim == (4, 4):
          # TODO[dwierichs]: Implement decomposition of broadcasted unitary
          if is_batched:
              raise DecompositionUndefinedError(
                  "The decomposition of a two-qubit QubitUnitary does not support broadcasting."
              )
  
          return qml.ops.two_qubit_decomposition(U, Wires(wires))
  
      return super(QubitUnitary, QubitUnitary).compute_decomposition(
          U, wires=wires
      )
  
imports: import warnings
  from itertools import product
  import numpy
  from scipy.linalg import fractional_matrix_power
  from pennylane.math import norm, cast, eye, zeros, transpose, conj, sqrt, sqrt_matrix
  from pennylane import numpy
  import pennylane
  from pennylane.operation import AnyWires, DecompositionUndefinedError, Operation
  from pennylane.wires import Wires
label_desc: Use image node_id 3 for calling the QubitUnitary obj's underlying member method code with example usage: obj.compute_decomposition(U, wires) and returns: super, qml, qml