class_docstr: Unit tests for the pennylane.qnn.keras.KerasLayer class.
class_docstr_tok: ["Unit","tests","for","the","pennylane.qnn.keras.KerasLayer","class","."]
docstr: Test if KerasLayer is compatible with the backprop diff method.
docstr_tok: ["Test","if","KerasLayer","is","compatible","with","the","backprop","diff","method","."]
code: def test_backprop_gradients(
      self, mocker
  ):  # pylint: disable=no-self-use
      """Test if KerasLayer is compatible with the backprop diff method."""
  
      dev = qml.device("default.qubit.tf", wires=2)
  
      @qml.qnode(dev, interface="tf", diff_method="backprop")
      def f(inputs, weights):
          qml.templates.AngleEmbedding(inputs, wires=range(2))
          qml.templates.StronglyEntanglingLayers(
              weights, wires=range(2)
          )
          return [qml.expval(qml.PauliZ(i)) for i in range(2)]
  
      weight_shapes = {"weights": (3, 2, 3)}
  
      qlayer = qml.qnn.KerasLayer(f, weight_shapes, output_dim=2)
  
      inputs = tf.ones((4, 2))
  
      with tf.GradientTape() as tape:
          out = tf.reduce_sum(qlayer(inputs))
  
      spy = mocker.spy(qml.gradients, "param_shift")
  
      grad = tape.gradient(out, qlayer.trainable_weights)
      assert grad is not None
      spy.assert_not_called()
  
imports: from collections import defaultdict
  import numpy
  import pytest
  import pennylane
label_desc: Use image node_id 19 for calling the TestKerasLayer obj's underlying member method code with example usage: obj.test_backprop_gradients(mocker) and returns: unknown