class_docstr: Tests for the step_and_cost method
docstr: Test that the cost is correctly returned
  when using a QNode as the cost function
docstr_tok: ["Test","that","the","cost","is","correctly","returned","when","using","a","QNode","as","the","cost","function"]
code: def test_qnode_cost(self, tol):
      """Test that the cost is correctly returned
      when using a QNode as the cost function"""
      np.random.seed(0)
  
      dev = qml.device("default.qubit", wires=1, shots=10)
  
      @qml.qnode(dev, cache=False)
      def circuit(x):
          qml.RX(x[0], wires=0)
          qml.RY(x[1], wires=0)
          return qml.expval(qml.PauliZ(0))
  
      params = np.array([0.1, 0.3], requires_grad=True)
  
      opt = qml.ShotAdaptiveOptimizer(min_shots=10)
  
      for _ in range(100):
          params, res = opt.step_and_cost(circuit, params)
  
      assert np.allclose(res, -1, atol=tol, rtol=0)
  
imports: import pytest
  from flaky import flaky
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 1 for calling the TestStepAndCost obj's underlying member method code with example usage: obj.test_qnode_cost(tol) and returns: qml