docstr: Test that `Sum` expectation values are correct when tensor contraction
  is used for computation.
docstr_tok: ["Test","that","`","Sum","`","expectation","values","are","correct","when","tensor","contraction","is","used","for","computation","."]
code: def test_sum_expval_tensor_contraction(self):
      """Test that `Sum` expectation values are correct when tensor contraction
      is used for computation."""
      summands = (
          qml.prod(qml.PauliY(i), qml.PauliZ(i + 1)) for i in range(7)
      )
      obs = qml.sum(*summands)
      ops = [qml.RX(0.123, wires=i) for i in range(8)]
      meas = [qml.expval(obs)]
      qs = qml.tape.QuantumScript(ops, meas)
  
      res = simulate(qs)
      expected = 7 * (-np.sin(0.123) * np.cos(0.123))
      assert np.allclose(res, expected)
  
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 3 for calling the TestMeasurements obj's underlying member method code with example usage: obj.test_sum_expval_tensor_contraction() without return types