docstr: Test step_and_cost() function with the qnode with non-trainable input.
docstr_tok: ["Test","step_and_cost","(",")","function","with","the","qnode","with","non-trainable","input","."]
code: def test_step_and_cost_with_non_trainable_input(
      self, finite_diff_step, seed
  ):
      """Test step_and_cost() function with the qnode with non-trainable input."""
      regularization = 1e-3
      stepsize = 1e-2
      opt = qml.QNSPSAOptimizer(
          stepsize=stepsize,
          regularization=regularization,
          finite_diff_step=finite_diff_step,
          resamplings=1,
          blocking=True,
          history_length=5,
          seed=seed,
      )
      # a deep copy of the same opt, to be applied to qnode_reduced
      target_opt = deepcopy(opt)
      dev = qml.device("default.qubit", wires=2)
      non_trainable_param = np.random.rand(1)
      non_trainable_param.requires_grad = False
  
      trainable_param = np.random.rand(1)
  
      @qml.qnode(dev)
      def qnode_with_non_trainable(trainable, non_trainable):
          qml.RY(trainable, wires=0)
          qml.CRX(non_trainable, wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
  
      # reduced qnode where non-trainable param value is hard coded
      @qml.qnode(dev)
      def qnode_reduced(trainable):
          qml.RY(trainable, wires=0)
          qml.CRX(non_trainable_param, wires=[0, 1])
          return qml.expval(qml.PauliZ(0) @ qml.PauliZ(1))
  
      new_params_res, qnode_res = opt.step_and_cost(
          qnode_with_non_trainable, trainable_param, non_trainable_param
      )
      new_trainable_res, new_non_trianable_res = new_params_res
  
      new_trainable_expected, qnode_expected = target_opt.step_and_cost(
          qnode_reduced, trainable_param
      )
  
      assert np.allclose(qnode_res, qnode_expected)
      assert np.allclose(new_non_trianable_res, non_trainable_param)
      assert np.allclose(new_trainable_res, new_trainable_expected)
  
file_path: pennylane/tests/optimize/test_qnspsa.py
imports: from copy import deepcopy
  import pytest
  from scipy.linalg import sqrtm
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 7 for calling the TestQNSPSAOptimizer obj's underlying member method code with example usage: obj.test_step_and_cost_with_non_trainable_input(finite_diff_step, seed) and returns: qml, qml