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 the call() method performs correctly when the inputs argument has an arbitrary shape (that can
  correctly be broadcast over), i.e., for input of shape (batch_size, dn, ... , d0) it outputs with shape
  (batch_size, dn, ... , d1, output_dim). Also tests if gradients are still backpropagated correctly.
docstr_tok: ["Test","if","the","call","(",")","method","performs","correctly","when","the","inputs","argument","has","an","arbitrary","shape","(","that","can","correctly","be","broadcast","over",")",",","i.e.",",","for","input","of","shape","(","batch_size",",","dn",",","...",",","d0",")","it","outputs","with","shape","(","batch_size",",","dn",",","...",",","d1",",","output_dim",")",".","Also","tests","if","gradients","are","still","backpropagated","correctly","."]
code: def test_call_broadcast(
      self, get_circuit, output_dim, middle_dim, batch_size, n_qubits
  ):  # pylint: disable=no-self-use,too-many-arguments
      """Test if the call() method performs correctly when the inputs argument has an arbitrary shape (that can
      correctly be broadcast over), i.e., for input of shape (batch_size, dn, ... , d0) it outputs with shape
      (batch_size, dn, ... , d1, output_dim). Also tests if gradients are still backpropagated correctly.
      """
      c, w = get_circuit
      layer = KerasLayer(c, w, output_dim)
      x = tf.ones((batch_size, middle_dim, n_qubits))
  
      with tf.GradientTape() as tape:
          layer_out = layer(x)
  
      g_layer = tape.gradient(layer_out, layer.trainable_variables)
  
      # test gradients are at least calculated
      assert g_layer is not None
      assert layer_out.shape == (batch_size, middle_dim, output_dim)
  
imports: from collections import defaultdict
  import numpy
  import pytest
  import pennylane
label_desc: Use image node_id 16 for calling the TestKerasLayer obj's underlying member method code with example usage: obj.test_call_broadcast(get_circuit, output_dim, middle_dim, batch_size, n_qubits) without return types