code: def test_flatten_unflatten():
      """Tests the flatten and unflatten methods."""
      op = qml.QuantumPhaseEstimation(
          np.eye(4), target_wires=(0, 1), estimation_wires=[2, 3]
      )
      data, metadata = op._flatten()
      expected_data = qml.QubitUnitary(np.eye(4), (0, 1))
      assert qml.equal(data[0], expected_data)
  
      assert metadata[0] == qml.wires.Wires((2, 3))
  
      # make sure metadata is hashable
      assert hash(metadata)
  
      new_op = type(op)._unflatten(*op._flatten())
      assert qml.equal(op, new_op)
      assert op is not new_op
  
file_path: pennylane/tests/templates/test_subroutines/test_qpe.py
imports: import pytest
  import numpy
  from scipy.stats import unitary_group
  import pennylane
label_desc: Use image node_id 1 for calling a global function with example usage: test_flatten_unflatten() without return types