class_docstr: Tests that the template defines the correct decomposition.
class_docstr_tok: ["Tests","that","the","template","defines","the","correct","decomposition","."]
docstr: Test that the _flatten and _unflatten functions work as expected.
docstr_tok: ["Test","that","the","_flatten","and","_unflatten","functions","work","as","expected","."]
code: def test_flatten_unflatten(self):
      """Test that the _flatten and _unflatten functions work as expected."""
      ops = [
          qml.PauliX(wires=2),
          qml.PauliX(wires=3),
          qml.PauliY(wires=2),
          qml.SWAP([2, 3]),
      ]
      op = qml.Select(ops, control=[0, 1])
      data, metadata = op._flatten()
  
      assert hash(metadata)
  
      assert len(data) == len(ops)
      assert all(qml.equal(op1, op2) for op1, op2 in zip(data, ops))
  
      assert metadata == op.control
  
      new_op = type(op)._unflatten(*op._flatten())
      assert all(
          qml.equal(op1, op2) for op1, op2 in zip(op.ops, new_op.ops)
      )
      assert op.wires == new_op.wires
      assert op.control == new_op.control
      assert op.target_wires == new_op.target_wires
      assert op is not new_op
  
imports: import copy
  import pytest
  import numpy
  from pennylane import numpy
  import pennylane
label_desc: Use image node_id 4 for calling the TestSelect obj's underlying member method code with example usage: obj.test_flatten_unflatten() without return types