class_docstr: Tests for the expval function
class_docstr_tok: ["Tests","for","the","expval","function"]
docstr: Test that the expval interface works
docstr_tok: ["Test","that","the","expval","interface","works"]
code: def test_batched_hamiltonian(self):
      """Test that the expval interface works"""
      dev = qml.device("default.qubit")
      ops = (
          qml.Hadamard(0),
          qml.PauliZ(0) @ qml.PauliY(1) @ qml.PauliY(2) @ qml.PauliX(3),
      )
      H = qml.Hamiltonian([0.5, 1.0], ops)
  
      @qml.qnode(
          dev, interface="autograd", diff_method="parameter-shift"
      )
      def cost_circuit(params):
          qml.RX(params, 0)
          qml.CNOT([0, 1])
          return qml.expval(H)
  
      rng = np.random.default_rng(42)
      params = rng.normal(0, np.pi, 4)
      energy = [cost_circuit(p) for p in params]
      energy_batched = cost_circuit(params)
  
      assert qml.math.allequal(energy_batched, energy)
  
imports: import copy
  import numpy
  import pytest
  import pennylane
  from pennylane.measurements import Expectation, Shots
  from pennylane.measurements.expval import ExpectationMP
label_desc: Use image node_id 17 for calling the TestExpval obj's underlying member method code with example usage: obj.test_batched_hamiltonian() and returns: qml