docstr: Test that the QNSPSA metric tensor estimation(before regularization) is correct by
  comparing the optimizer result to the analytical result.
docstr_tok: ["Test","that","the","QNSPSA","metric","tensor","estimation","(","before","regularization",")","is","correct","by","comparing","the","optimizer","result","to","the","analytical","result","."]
code: def test_raw_metric_tensor(self, finite_diff_step, seed):
      """Test that the QNSPSA metric tensor estimation(before regularization) is correct by
      comparing the optimizer result to the analytical result."""
      opt = qml.QNSPSAOptimizer(
          stepsize=1e-3,
          regularization=1e-3,
          finite_diff_step=finite_diff_step,
          resamplings=1,
          blocking=True,
          history_length=5,
          seed=seed,
      )
  
      qnode, params_shape = get_single_input_qnode()
      params = np.random.rand(*params_shape)
  
      # raw metric tensor result from QNSPSAOptimizer
      metric_tapes, tensor_dirs = opt._get_tensor_tapes(
          qnode, [params], {}
      )
      raw_results = qml.execute(metric_tapes, qnode.device, None)
      metric_tensor_res = opt._post_process_tensor(
          raw_results, tensor_dirs
      )
  
      # expected raw metric tensor from analytical state overlap
      metric_tensor_expected = get_metric_from_single_input_qnode(
          params, finite_diff_step, tensor_dirs
      )
      assert np.allclose(metric_tensor_res, metric_tensor_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 2 for calling the TestQNSPSAOptimizer obj's underlying member method code with example usage: obj.test_raw_metric_tensor(finite_diff_step, seed) without return types