code: def test_flatten_unflatten():
      """Test the flatten and unflatten methods."""
  
      def block(weights, wires, use_CNOT=True):
          if use_CNOT:
              qml.CNOT(wires=[wires[0], wires[1]])
          qml.RY(weights[0], wires=wires[0])
          qml.RY(weights[1], wires=wires[1])
  
      n_wires = 4
      n_block_wires = 2
      n_params_block = 2
      n_blocks = qml.MPS.get_n_blocks(range(n_wires), n_block_wires)
      template_weights = [[0.1, -0.3]] * n_blocks
  
      wires = qml.wires.Wires((0, 1, 2, 3))
  
      op = qml.MPS(
          wires,
          n_block_wires,
          block,
          n_params_block,
          template_weights,
          use_CNOT=True,
      )
  
      data, metadata = op._flatten()
      assert len(data) == 1
      assert qml.math.allclose(data[0], template_weights)
  
      assert metadata[0] == wires
      assert dict(metadata[1]) == op.hyperparameters
  
      # make sure metadata hashable
      assert hash(metadata)
  
      new_op = qml.MPS._unflatten(*op._flatten())
      assert qml.equal(new_op, op)
      assert new_op._name == "MPS"  # make sure acutally initialized
      assert new_op is not op
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.templates.tensornetworks.mps import compute_indices_MPS, MPS
label_desc: Use image node_id 1 for calling a global function with example usage: test_flatten_unflatten() without return types