class_docstr: Tests to ensure the transform itself works in all interfaces.
docstr: Test that the transform works in the torch interface.
docstr_tok: ["Test","that","the","transform","works","in","the","torch","interface","."]
code: def test_unitary_to_rot_torch(
      self, U, expected_gates, expected_params
  ):
      """Test that the transform works in the torch interface."""
      import torch
  
      U = torch.tensor(U, dtype=torch.complex128)
  
      transformed_qfunc = unitary_to_rot(qfunc)
  
      ops = qml.tape.make_qscript(transformed_qfunc)(U).operations
  
      assert len(ops) == 5
  
      assert isinstance(ops[0], qml.Hadamard)
      assert ops[0].wires == Wires("a")
  
      for i in range(3):
          assert isinstance(ops[1 + i], expected_gates[i])
          assert ops[1 + i].wires == Wires("a")
          assert qml.math.allclose(
              qml.math.unwrap(ops[1 + i].parameters),
              expected_params[i],
              atol=1e-7,
          )
  
      assert isinstance(ops[4], qml.CNOT)
      assert ops[4].wires == Wires(["b", "a"])
  
imports: from itertools import product
  import pytest
  from gate_data import I, Z, S, T, H, X
  from test_optimization.utils import check_matrix_equivalence
  import pennylane
  from pennylane import numpy
  from pennylane.wires import Wires
  from pennylane.transforms import unitary_to_rot
label_desc: Use image node_id 4 for calling the TestDecomposeSingleQubitUnitaryTransform obj's underlying member method code with example usage: obj.test_unitary_to_rot_torch(U, expected_gates, expected_params) without return types