class_docstr: Unit tests for validate_and_expand_adjoint
class_docstr_tok: ["Unit","tests","for","validate_and_expand_adjoint"]
docstr: Test attempting to compute the gradient of a tape that obtains the
  expectation value of a Hermitian operator emits a warning if the
  parameters to Hermitian are trainable.
docstr_tok: ["Test","attempting","to","compute","the","gradient","of","a","tape","that","obtains","the","expectation","value","of","a","Hermitian","operator","emits","a","warning","if","the","parameters","to","Hermitian","are","trainable","."]
code: def test_trainable_hermitian_warns(self):
      """Test attempting to compute the gradient of a tape that obtains the
      expectation value of a Hermitian operator emits a warning if the
      parameters to Hermitian are trainable."""
  
      mx = qml.matrix(qml.PauliX(0) @ qml.PauliY(2))
      qs = qml.tape.QuantumScript(
          [], [qml.expval(qml.Hermitian(mx, wires=[0, 2]))]
      )
  
      qs.trainable_params = {0}
  
      program = qml.device("default.qubit").preprocess(
          ExecutionConfig(gradient_method="adjoint")
      )[0]
  
      with pytest.warns(
          UserWarning,
          match="Differentiating with respect to the input parameters of Hermitian",
      ):
          _ = program((qs,))
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.devices import DefaultQubit, ExecutionConfig
  from pennylane.devices.default_qubit import stopping_condition
label_desc: Use image node_id 7 for calling the TestAdjointDiffTapeValidation obj's underlying member method code with example usage: obj.test_trainable_hermitian_warns() without return types