class_docstr: Test that get_measurement_function dispatchs to the correct place.
docstr: Check that the sum of terms method is used when the state is trainable.
docstr_tok: ["Check","that","the","sum","of","terms","method","is","used","when","the","state","is","trainable","."]
code: def test_hamiltonian_sum_of_terms_when_backprop(self):
      """Check that the sum of terms method is used when the state is trainable."""
      H = qml.Hamiltonian([2], [qml.PauliX(0)])
      state = qml.numpy.zeros(2)
      assert (
          get_measurement_function(qml.expval(H), state)
          is sum_of_terms_method
      )
  
imports: import pytest
  import numpy
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane.devices.qubit import simulate
  from pennylane.devices.qubit.measure import measure, state_diagonalizing_gates, csr_dot_products, full_dot_products, get_measurement_function, sum_of_terms_method
label_desc: Use image node_id 5 for calling the TestMeasurementDispatch obj's underlying member method code with example usage: obj.test_hamiltonian_sum_of_terms_when_backprop() without return types