code: def test_flatten_unflatten():
      """Tests the flatten and unflatten methods."""
      weights = qml.math.array([[0.55, 0.72, 0.6, 0.54, 0.42, 0.65]])
      wires = qml.wires.Wires((0, 1, 2, 3))
      init_state = qml.math.array([1, 1, 0, 0])
      op = qml.kUpCCGSD(
          weights,
          wires=wires,
          k=1,
          delta_sz=0,
          init_state=init_state,
      )
      data, metadata = op._flatten()
      assert data == (weights,)
      assert len(metadata) == 2
      assert metadata[0] == wires
      assert metadata[1] == (
          ("k", 1),
          ("delta_sz", 0),
          ("init_state", tuple(init_state)),
      )
  
      # make sure metadata hashable
      assert hash(metadata)
  
      new_op = type(op)._unflatten(*op._flatten())
      assert op.data == new_op.data
      assert type(new_op) is type(op)
      assert (
          op.hyperparameters["s_wires"]
          == new_op.hyperparameters["s_wires"]
      )
      assert (
          op.hyperparameters["d_wires"]
          == new_op.hyperparameters["d_wires"]
      )
      assert op.hyperparameters["k"] == new_op.hyperparameters["k"]
      assert (
          op.hyperparameters["delta_sz"]
          == new_op.hyperparameters["delta_sz"]
      )
      assert qml.math.allclose(
          op.hyperparameters["init_state"],
          new_op.hyperparameters["init_state"],
      )
  
      assert op is not new_op
  
imports: import pytest
  import numpy
  import pennylane
label_desc: Use image node_id 1 for calling a global function with example usage: test_flatten_unflatten() without return types