def METHOD_NAME(self):
    """Tests correct gradients are produced when the Hamiltonian is differentiable."""
    n_wires = 2
    dev = qml.device("default.qubit", wires=n_wires)
    obs = [qml.PauliX(0) @ qml.PauliY(1), qml.PauliY(0) @ qml.PauliX(1)]
    diff_coeffs = np.array([1.0, -1.0], requires_grad=True)
    frequencies = (2, 4)
    def parameterized_hamiltonian(coeffs):
        return qml.Hamiltonian(coeffs, obs)
    @qml.qnode(dev)
    def circuit(time, coeffs):
        qml.PauliX(0)
        qml.CommutingEvolution(parameterized_hamiltonian(coeffs), time, frequencies)
        return qml.expval(qml.PauliZ(0))
    x_vals = [np.array(x, requires_grad=True) for x in np.linspace(-np.pi, np.pi, num=10)]
    grads_finite_diff = [
        np.hstack(qml.gradients.finite_diff(circuit)(x, diff_coeffs)) for x in x_vals
    ]
    grads_param_shift = [
        np.hstack(qml.gradients.param_shift(circuit)(x, diff_coeffs)) for x in x_vals
    ]
    assert np.isclose(grads_finite_diff, grads_param_shift, atol=1e-6).all()