class_docstr: Test the SPSA optimizer.
docstr: Test that the correct param is returned via the step method
  with a multidimensional input.
docstr_tok: ["Test","that","the","correct","param","is","returned","via","the","step","method","with","a","multidimensional","input","."]
code: def test_step_spsa_single_multid_input(self):
      """Test that the correct param is returned via the step method
      with a multidimensional input."""
      spsa_opt = qml.SPSAOptimizer(maxiter=10)
      multid_array = np.array([[0.1, 0.2], [-0.1, -0.4]])
  
      @qml.qnode(qml.device("default.qubit", wires=1))
      def quant_fun_mdarr(var):
          qml.RX(var[0, 0], wires=[0])
          qml.RX(var[0, 1], wires=[0])
          qml.RY(var[1, 0], wires=[0])
          qml.RY(var[1, 1], wires=[0])
          return qml.expval(qml.PauliZ(0))
  
      alpha = 0.602
      gamma = 0.101
      c = 0.2
      A = 1.0
      a = 0.05 * (A + 1) ** alpha
      k = 1
      ck = c / k**gamma
      ak = a / (A + k) ** alpha
      # pylint:disable=too-many-function-args
      deltas = np.array(
          np.meshgrid([1, -1], [1, -1], [1, -1], [1, -1])
      ).T.reshape(-1, 2, 2)
  
      args = (multid_array,)
      y_pm = []
      for delta in deltas:
          thetaplus = list(args)
          thetaminus = list(args)
          for index, arg in enumerate(args):
              multiplier = ck * delta
              thetaplus[index] = arg + multiplier
              thetaminus[index] = arg - multiplier
          yplus = np.array([quant_fun_mdarr(p) for p in thetaplus])
          yminus = np.array([quant_fun_mdarr(p) for p in thetaminus])
          y_pm.append(yplus - yminus)
      # choose one delta
      d = 0
      grad = np.array([y_pm[d] / (2 * ck * deltas[d])])
      tol = ak * max(np.abs(y_pm)) / ck
  
      expected = multid_array - ak * grad
  
      res = spsa_opt.step(quant_fun_mdarr, multid_array)
  
      assert np.allclose(res, expected, atol=tol)
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 8 for calling the TestSPSAOptimizer obj's underlying member method code with example usage: obj.test_step_spsa_single_multid_input() and returns: qml