class_docstr: Unit tests for the hadamard_grad function
class_docstr_tok: ["Unit","tests","for","the","hadamard_grad","function"]
docstr: Test that the transform output shape matches that of the QNode.
code: def test_output_shape_matches_qnode_expval(
      self, cost, expected_shape
  ):
      """Test that the transform output shape matches that of the QNode."""
      dev = qml.device("default.qubit", wires=4)
  
      x = np.random.rand(3)
      circuit = qml.QNode(cost, dev)
  
      res_hadamard = qml.gradients.hadamard_grad(circuit)(x)
  
      assert isinstance(res_hadamard, (tuple, list))
      if len(res_hadamard) == 1:
          res_hadamard = res_hadamard[0]
      assert len(res_hadamard) == expected_shape[0]
  
      if len(expected_shape) > 1:
          for r in res_hadamard:
              assert isinstance(r, tuple)
              assert len(r) == expected_shape[1]
  
imports: import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 16 for calling the TestHadamardGrad obj's underlying member method code with example usage: obj.test_output_shape_matches_qnode_expval(cost, expected_shape) without return types