code: def test_flatten_unflatten():
      """Test the _flatten and _unflatten methods."""
      weight = 0.5
      wires1 = qml.wires.Wires((0, 1))
      wires2 = qml.wires.Wires((2, 3, 4))
      op = qml.FermionicDoubleExcitation(
          weight, wires1=wires1, wires2=wires2
      )
  
      data, metadata = op._flatten()
      assert data == (0.5,)
      assert metadata[0] == wires1
      assert metadata[1] == wires2
  
      # test that its 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_double_excitation.py
imports: import pytest
  import numpy
  from pennylane import numpy
  import pennylane
label_desc: Use image node_id 2 for calling a global function with example usage: test_flatten_unflatten() without return types