def test_qnode_array_parameters_2_vector_return(self, qubit_device_2_wires, tol):
    'Test that QNode can take arrays as input arguments, and that they interact properly with TensorFlow\n           Test case for a circuit that returns a 2-vector.'

    @qml.qnode(qubit_device_2_wires, interface='tf')
    def circuit(dummy1, array, dummy2):
        qml.RY((0.5 * array[(0, 1)]), wires=0)
        qml.RY(((- 0.5) * array[(1, 1)]), wires=0)
        qml.RY(array[(1, 0)], wires=1)
        return (qml.expval(qml.PauliX(0)), qml.expval(qml.PauliX(1)))
    grad_target = (np.array(1.0), np.array([[0.5, 0.43879, 0], [0, (- 0.43879), 0]]), np.array((- 0.4)))
    cost_target = 1.03257
    args = (Variable(0.46), Variable([[2.0, 3.0, 0.3], [7.0, 4.0, 2.1]]), Variable((- 0.13)))

    def cost(x, array, y):
        c = tf.cast(circuit(tf.constant(0.111), array, tf.constant(4.5)), tf.float32)
        c = c[0]
        return (((c + (0.5 * array[(0, 0)])) + x) - (0.4 * y))
    with tf.GradientTape() as tape:
        cost_res = cost(*args)
        grad_res = np.array([i.numpy() for i in tape.gradient(cost_res, [args[0], args[2]])])
    assert np.allclose(cost_res.numpy(), cost_target, atol=tol, rtol=0)
    assert np.allclose(grad_res, np.fromiter(grad_target[::2], dtype=np.float32), atol=tol, rtol=0)
Test that QNode can take arrays as input arguments, and that they interact properly with TensorFlow
Test case for a circuit that returns a 2-vector.
def test_qnode_array_parameters_2_vector_return(self, qubit_device_2_wires, tol):
    'Test that QNode can take arrays as input arguments, and that they interact properly with TensorFlow\n           Test case for a circuit that returns a 2-vector.'

    @qml.qnode(qubit_device_2_wires, interface='tf')
    def circuit(dummy1, array, dummy2):
        qml.RY((0.5 * array[(0, 1)]), wires=0)
        qml.RY(((- 0.5) * array[(1, 1)]), wires=0)
        qml.RY(array[(1, 0)], wires=1)
        return (qml.expval(qml.PauliX(0)), qml.expval(qml.PauliX(1)))
    grad_target = (np.array(1.0), np.array([[0.5, 0.43879, 0], [0, (- 0.43879), 0]]), np.array((- 0.4)))
    cost_target = 1.03257
    args = (Variable(0.46), Variable([[2.0, 3.0, 0.3], [7.0, 4.0, 2.1]]), Variable((- 0.13)))

    def cost(x, array, y):
        c = tf.cast(circuit(tf.constant(0.111), array, tf.constant(4.5)), tf.float32)
        c = c[0]
        return (((c + (0.5 * array[(0, 0)])) + x) - (0.4 * y))
    with tf.GradientTape() as tape:
        cost_res = cost(*args)
        grad_res = np.array([i.numpy() for i in tape.gradient(cost_res, [args[0], args[2]])])
    assert np.allclose(cost_res.numpy(), cost_target, atol=tol, rtol=0)
    assert np.allclose(grad_res, np.fromiter(grad_target[::2], dtype=np.float32), atol=tol, rtol=0)