class_docstr: Test caching for device jacobians.
class_docstr_tok: ["Test","caching","for","device","jacobians","."]
docstr: test that only jacs are cached on calls to compute_vjp.
docstr_tok: ["test","that","only","jacs","are","cached","on","calls","to","compute_vjp","."]
code: def test_cached_on_vjps(self, jpc):
      """test that only jacs are cached on calls to compute_vjp."""
  
      tape1 = qml.tape.QuantumScript(
          [qml.RZ(0.5, wires=0)], [qml.expval(qml.PauliX(0))]
      )
      batch = (tape1,)
      dy = ((0.5,),)
  
      with jpc._device.tracker:
          jpc.compute_vjp(batch, dy)
  
      if isinstance(jpc._device, ParamShiftDerivativesDevice):
          expected = 2
      elif isinstance(jpc._device, qml.devices.Device):
          expected = 0
      else:
          expected = 1
  
      assert jpc._device.tracker.totals.get("executions", 0) == expected
  
      assert batch not in jpc._results_cache
      assert qml.math.allclose(jpc._jacs_cache[batch], 0)
  
      with jpc._device.tracker:
          jpc.execute_and_compute_jvp(batch, ((0.5,),))
  
      assert jpc._device.tracker.totals["executions"] == 1
      assert jpc._device.tracker.totals.get("derivatives", 0) == 0
      assert qml.math.allclose(jpc._results_cache[batch], 0)
  
imports: import pytest
  from cachetools import LRUCache
  from param_shift_dev import ParamShiftDerivativesDevice
  import numpy
  import pennylane
  from pennylane.workflow.jacobian_products import JacobianProductCalculator, TransformJacobianProducts, DeviceDerivatives, DeviceJacobianProducts, LightningVJPs
label_desc: Use image node_id 4 for calling the TestCachingDeviceDerivatives obj's underlying member method code with example usage: obj.test_cached_on_vjps(jpc) without return types