class_docstr: Test that the template defines the correct decomposition.
class_docstr_tok: ["Test","that","the","template","defines","the","correct","decomposition","."]
docstr: Test that the TwoLocalSwapNetwork template works correctly by asserting the prepared state.
docstr_tok: ["Test","that","the","TwoLocalSwapNetwork","template","works","correctly","by","asserting","the","prepared","state","."]
code: def test_ccl2(
      self,
      num_wires,
      acquaintances,
      weights,
      fermionic,
      shift,
      exp_state,
  ):
      """Test that the TwoLocalSwapNetwork template works correctly by asserting the prepared state."""
  
      wires = range(num_wires)
  
      shape = qml.templates.TwoLocalSwapNetwork.shape(num_wires)
      weights = np.pi / 2 * qml.math.ones(shape) if weights else None
  
      dev = qml.device("default.qubit", wires=wires)
  
      @qml.qnode(dev)
      def circuit():
          qml.PauliX(wires=[0])
          qml.PauliX(wires=[2])
          qml.templates.TwoLocalSwapNetwork(
              wires, acquaintances, weights, fermionic, shift
          )
          return qml.state()
  
      assert qml.math.allclose(circuit(), exp_state, atol=1e-8)
  
imports: import pytest
  from pennylane import numpy
  import pennylane
label_desc: Use image node_id 3 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_ccl2(num_wires, acquaintances, weights, fermionic, shift, exp_state) and returns: qml