class_docstr: Test that tapes ending with expectations
  of Hamiltonians provide correct results and gradients
class_docstr_tok: ["Test","that","tapes","ending","with","expectations","of","Hamiltonians","provide","correct","results","and","gradients"]
docstr: Test hamiltonian with no trainable parameters.
docstr_tok: ["Test","hamiltonian","with","no","trainable","parameters","."]
code: def test_multiple_hamiltonians_not_trainable(
      self, execute_kwargs, cost_fn, shots, use_new_op_math
  ):
      """Test hamiltonian with no trainable parameters."""
  
      if (
          execute_kwargs["gradient_fn"] == "adjoint"
          and not use_new_op_math
      ):
          pytest.skip(
              "adjoint differentiation does not suppport hamiltonians."
          )
  
      coeffs1 = torch.tensor([0.1, 0.2, 0.3], requires_grad=False)
      coeffs2 = torch.tensor([0.7], requires_grad=False)
      weights = torch.tensor([0.4, 0.5], requires_grad=True)
  
      res = cost_fn(weights, coeffs1, coeffs2)
      expected = self.cost_fn_expected(weights, coeffs1, coeffs2)
      if shots.has_partitioned_shots:
          assert torch.allclose(
              res[:2], expected, atol=atol_for_shots(shots), rtol=0
          )
          assert torch.allclose(
              res[2:], expected, atol=atol_for_shots(shots), rtol=0
          )
      else:
          assert torch.allclose(
              res, expected, atol=atol_for_shots(shots), rtol=0
          )
  
      res = torch.autograd.functional.jacobian(
          lambda w: cost_fn(w, coeffs1, coeffs2), weights
      )
      expected = self.cost_fn_jacobian(weights, coeffs1, coeffs2)[:, :2]
      if shots.has_partitioned_shots:
          assert torch.allclose(
              res[:2, :], expected, atol=atol_for_shots(shots), rtol=0
          )
          assert torch.allclose(
              res[2:, :], expected, atol=atol_for_shots(shots), rtol=0
          )
      else:
          assert torch.allclose(
              res, expected, atol=atol_for_shots(shots), rtol=0
          )
  
imports: import numpy
  import pytest
  from param_shift_dev import ParamShiftDerivativesDevice
  import pennylane
  from pennylane.devices import DefaultQubit
  from pennylane.gradients import param_shift
  from pennylane import execute
  from pennylane.measurements import Shots
label_desc: Use image node_id 4 for calling the TestHamiltonianWorkflows obj's underlying member method code with example usage: obj.test_multiple_hamiltonians_not_trainable(execute_kwargs, cost_fn, shots, use_new_op_math) without return types