class_docstr: Tests for the gradient expand function
class_docstr_tok: ["Tests","for","the","gradient","expand","function"]
docstr: Test that a circuit with non-differentiable
  trainable operations is expanded
docstr_tok: ["Test","that","a","circuit","with","non-differentiable","trainable","operations","is","expanded"]
code: def test_trainable_nondiff_expansion(self, mocker):
      """Test that a circuit with non-differentiable
      trainable operations is expanded"""
      x = qml.numpy.array(0.2, requires_grad=True)
      y = qml.numpy.array(0.1, requires_grad=True)
  
      class NonDiffPhaseShift(qml.PhaseShift):
          grad_method = None
  
      with qml.queuing.AnnotatedQueue() as q:
          NonDiffPhaseShift(x, wires=0)
          qml.RY(y, wires=1)
          qml.CNOT(wires=[0, 1])
          qml.expval(qml.PauliZ(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      spy = mocker.spy(tape, "expand")
      new_tape = qml.transforms.expand_invalid_trainable(tape)
  
      assert new_tape is not tape
      spy.assert_called()
  
      assert new_tape.operations[0].name == "RZ"
      assert new_tape.operations[0].grad_method == "A"
      assert new_tape.operations[1].name == "GlobalPhase"
      assert new_tape.operations[2].name == "RY"
      assert new_tape.operations[3].name == "CNOT"
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 2 for calling the TestExpandInvalidTrainable obj's underlying member method code with example usage: obj.test_trainable_nondiff_expansion(mocker) without return types