class_docstr: Tests for vectorized optimizers when there are unconnected nodes.
  
  Subclassed Keras models can have layers that are defined in the graph, but
  not connected to the input or output. Or a condition expression could
  determine if the layer in question was connected or not. In such cases, the
  gradients are not present for that unconnected layer. The vectorized DP
  optimizers compute the per-microbatch losses using the Jacobian. The Jacobian
  will contain 'None' values corresponding to that layer. This causes an error
  in the gradient computation.
  This error can be mitigated by setting those unconnected gradients to 0
  instead of 'None'. This is done using the 'unconnected_gradients' flag of the
  tf.GradientTape.jacobian() method.
  This class of tests tests the possible combinations of presence/absence of
  unconnected layers and setting unconnected gradients to 'None' or 0. In these
  tests, this is done by setting 'unconnected_gradients_to_zero' to True if the
  gradients are to be set to zero, or False if they are to be set to None.
class_docstr_tok: ["Tests","for","vectorized","optimizers","when","there","are","unconnected","nodes",".","Subclassed","Keras","models","can","have","layers","that","are","defined","in","the","graph",",","but","not","connected","to","the","input","or","output",".","Or","a","condition","expression","could","determine","if","the","layer","in","question","was","connected","or","not",".","In","such","cases",",","the","gradients","are","not","present","for","that","unconnected","layer",".","The","vectorized","DP","optimizers","compute","the","per-microbatch","losses","using","the","Jacobian",".","The","Jacobian","will","contain","'None","'","values","corresponding","to","that","layer",".","This","causes","an","error","in","the","gradient","computation",".","This","error","can","be","mitigated","by","setting","those","unconnected","gradients","to","0","instead","of","'None","'",".","This","is","done","using","the","'unconnected_gradients","'","flag","of","the","tf.GradientTape.jacobian","(",")","method",".","This","class","of","tests","tests","the","possible","combinations","of","presence\/absence","of","unconnected","layers","and","setting","unconnected","gradients","to","'None","'","or","0",".","In","these","tests",",","this","is","done","by","setting","'unconnected_gradients_to_zero","'","to","True","if","the","gradients","are","to","be","set","to","zero",",","or","False","if","they","are","to","be","set","to","None","."]
docstr: Tests that DP vectorized optimizers with 'Zero' unconnected gradients pass.
      
code: def testUnconnectedGradientsAsZeroPasses(
      self, optimizer_class, use_sequence_output
  ):
      """Tests that DP vectorized optimizers with 'Zero' unconnected gradients pass."""
  
      embedding_model = keras_embedding_model_fn(
          optimizer_class,
          l2_norm_clip=1.0,
          noise_multiplier=0.5,
          num_microbatches=1,
          learning_rate=1.0,
          use_sequence_output=use_sequence_output,
          unconnected_gradients_to_zero=True,
      )
  
      train_data = np.random.randint(
          0, 10, size=(1000, 4), dtype=np.int32
      )
      train_labels = np.random.randint(
          0, 2, size=(1000, 1), dtype=np.int32
      )
  
      def train_data_input_fn():
          return tf.data.Dataset.from_tensor_slices(
              (train_data, train_labels)
          ).batch(8)
  
      try:
          embedding_model.fit(
              x=train_data_input_fn(), epochs=1, verbose=0
          )
      except ValueError:
          # For a 'ValueError' exception the test should record a failure. All
          # other exceptions are errors.
          self.fail("ValueError raised by model.fit().")
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras_vectorized
label_desc: Use image node_id 3 for calling the DPVectorizedOptimizerUnconnectedNodesTest obj's underlying member method code with example usage: obj.testUnconnectedGradientsAsZeroPasses(optimizer_class, use_sequence_output) and returns: tf