class_docstr: Test that stoch_pulse_grad integrates correctly with QNodes and ML interfaces.
class_docstr_tok: ["Test","that","stoch_pulse_grad","integrates","correctly","with","QNodes","and","ML","interfaces","."]
docstr: Test that a simple qnode that returns an expectation value
  can be differentiated with stoch_pulse_grad.
docstr_tok: ["Test","that","a","simple","qnode","that","returns","an","expectation","value","can","be","differentiated","with","stoch_pulse_grad","."]
code: def test_simple_qnode_expval_two_evolves(
      self, dev_name, num_split_times, shots, tol
  ):
      """Test that a simple qnode that returns an expectation value
      can be differentiated with stoch_pulse_grad."""
      import jax
      import jax.numpy as jnp
  
      jax.config.update("jax_enable_x64", True)
      key = "prng_key" if dev_name == "default.qubit.jax" else "seed"
      dev = qml.device(
          dev_name,
          wires=1,
          shots=shots,
          **{key: jax.random.PRNGKey(74)},
      )
      T_x = 0.1
      T_y = 0.2
      ham_x = qml.pulse.constant * qml.PauliX(0)
      ham_y = qml.pulse.constant * qml.PauliX(0)
  
      @qml.qnode(
          dev,
          interface="jax",
          diff_method=stoch_pulse_grad,
          num_split_times=num_split_times,
      )
      def circuit(params):
          qml.evolve(ham_x)(params[0], T_x)
          qml.evolve(ham_y)(params[1], T_y)
          return qml.expval(qml.PauliZ(0))
  
      params = [[jnp.array(0.4)], [jnp.array(-0.1)]]
      grad = jax.jacobian(circuit)(params)
      p_x = params[0][0] * T_x
      p_y = params[1][0] * T_y
      exp_grad = [
          [-2 * jnp.sin(2 * (p_x + p_y)) * T_x],
          [-2 * jnp.sin(2 * (p_x + p_y)) * T_y],
      ]
      assert qml.math.allclose(grad, exp_grad, atol=tol, rtol=0.0)
      jax.clear_caches()
  
imports: import warnings
  import copy
  import pytest
  import numpy
  import pennylane
  from pennylane.gradients.general_shift_rules import eigvals_to_frequencies, generate_shift_rule
  from pennylane.gradients.pulse_gradient import _parshift_and_integrate, _split_evol_ops, _split_evol_tape, stoch_pulse_grad
label_desc: Use image node_id 2 for calling the TestStochPulseGradIntegration obj's underlying member method code with example usage: obj.test_simple_qnode_expval_two_evolves(dev_name, num_split_times, shots, tol) and returns: qml