class_docstr: Test the RMSProp (root mean square propagation) optimizer
docstr: Tests that rmsprop optimizer takes one and two steps correctly
  for univariate functions.
docstr_tok: ["Tests","that","rmsprop","optimizer","takes","one","and","two","steps","correctly","for","univariate","functions","."]
code: def test_rmsprop_optimizer_univar(self, x_start, tol):
      """Tests that rmsprop optimizer takes one and two steps correctly
      for univariate functions."""
      stepsize, gamma = 0.1, 0.5
      rms_opt = RMSPropOptimizer(stepsize, decay=gamma)
  
      univariate_funcs = [
          np.sin,
          lambda x: np.exp(x / 10.0),
          lambda x: x**2,
      ]
      grad_uni_fns = [
          np.cos,
          lambda x: np.exp(x / 10.0) / 10.0,
          lambda x: 2 * x,
      ]
  
      for gradf, f in zip(grad_uni_fns, univariate_funcs):
          rms_opt.reset()
  
          x_onestep = rms_opt.step(f, x_start)
          past_grads = (1 - gamma) * gradf(x_start) * gradf(x_start)
          adapt_stepsize = stepsize / np.sqrt(past_grads + 1e-8)
          x_onestep_target = x_start - gradf(x_start) * adapt_stepsize
          assert np.allclose(x_onestep, x_onestep_target, atol=tol)
  
          x_twosteps = rms_opt.step(f, x_onestep)
          past_grads = (1 - gamma) * gamma * gradf(x_start) * gradf(
              x_start
          ) + (1 - gamma) * gradf(x_onestep) * gradf(x_onestep)
          adapt_stepsize = stepsize / np.sqrt(past_grads + 1e-8)
          x_twosteps_target = (
              x_onestep - gradf(x_onestep) * adapt_stepsize
          )
          assert np.allclose(x_twosteps, x_twosteps_target, atol=tol)
  
imports: import pytest
  from pennylane import numpy
  from pennylane.optimize import RMSPropOptimizer
label_desc: Use image node_id 2 for calling the TestRMSPropOptimizer obj's underlying member method code with example usage: obj.test_rmsprop_optimizer_univar(x_start, tol) without return types