class_docstr: Test for caching behaviour
class_docstr_tok: ["Test","for","caching","behaviour"]
docstr: Test the use of a custom cache object
docstr_tok: ["Test","the","use","of","a","custom","cache","object"]
code: def test_custom_cache(self, mocker):
      """Test the use of a custom cache object"""
      dev = qml.device("default.qubit.legacy", wires=1)
      spy = mocker.spy(qml.workflow, "cache_execute")
  
      def cost(a, cache):
          with qml.queuing.AnnotatedQueue() as q:
              qml.RY(a[0], wires=0)
              qml.RX(a[1], wires=0)
              qml.expval(qml.PauliZ(0))
  
          tape = qml.tape.QuantumScript.from_queue(q)
  
          return execute(
              [tape],
              dev,
              gradient_fn=param_shift,
              cache=cache,
          )[0]
  
      custom_cache = {}
      params = jax.numpy.array([0.1, 0.2])
      jax.grad(cost)(params, cache=custom_cache)
  
      cache = spy.call_args[0][1]
      assert cache is custom_cache
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.gradients import param_shift
  from pennylane import execute
label_desc: Use image node_id 2 for calling the TestCaching obj's underlying member method code with example usage: obj.test_custom_cache(mocker) and returns: execute