class_docstr: Test the SPSA optimizer.
docstr: Test that returned cost is correct.
docstr_tok: ["Test","that","returned","cost","is","correct","."]
code: def test_step_and_cost_supplied_univar_cost(self, args, f):
      """Test that returned cost is correct."""
      spsa_opt = qml.SPSAOptimizer(10)
      args = np.array(args, requires_grad=True)
  
      _, res = spsa_opt.step_and_cost(f, args)
      expected = f(args)
      assert np.all(res == expected)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 3 for calling the TestSPSAOptimizer obj's underlying member method code with example usage: obj.test_step_and_cost_supplied_univar_cost(args, f) without return types