def test_qnode_fanout(self, qubit_device_1_wire, tol):
    'Tests that qnodes can compute the correct function when the same parameter is used in multiple gates.'

    @qml.qnode(qubit_device_1_wire, interface='tf')
    def circuit(reused_param, other_param):
        qml.RX(reused_param, wires=[0])
        qml.RZ(other_param, wires=[0])
        qml.RX(reused_param, wires=[0])
        return qml.expval(qml.PauliZ(0))
    thetas = tf.linspace(((- 2) * np.pi), (2 * np.pi), 7)
    for reused_param in thetas:
        for theta in thetas:
            other_param = ((theta ** 2) / 11)
            y_eval = circuit(reused_param, other_param)
            Rx = Rotx(reused_param.numpy())
            Rz = Rotz(other_param.numpy())
            zero_state = np.array([1.0, 0.0])
            final_state = (((Rx @ Rz) @ Rx) @ zero_state)
            y_true = expZ(final_state)
            assert np.allclose(y_eval, y_true, atol=tol, rtol=0)
Tests that qnodes can compute the correct function when the same parameter is used in multiple gates.
def test_qnode_fanout(self, qubit_device_1_wire, tol):
    

    @qml.qnode(qubit_device_1_wire, interface='tf')
    def circuit(reused_param, other_param):
        qml.RX(reused_param, wires=[0])
        qml.RZ(other_param, wires=[0])
        qml.RX(reused_param, wires=[0])
        return qml.expval(qml.PauliZ(0))
    thetas = tf.linspace(((- 2) * np.pi), (2 * np.pi), 7)
    for reused_param in thetas:
        for theta in thetas:
            other_param = ((theta ** 2) / 11)
            y_eval = circuit(reused_param, other_param)
            Rx = Rotx(reused_param.numpy())
            Rz = Rotz(other_param.numpy())
            zero_state = np.array([1.0, 0.0])
            final_state = (((Rx @ Rz) @ Rx) @ zero_state)
            y_true = expZ(final_state)
            assert np.allclose(y_eval, y_true, atol=tol, rtol=0)