code: def test_generate_candidates(
      self,
      want_names,
      want_subnetwork_losses,
      want_mixture_weight_losses,
      want_complexities,
      learn_mixture_weights=False,
      initial_num_layers=0,
      previous_ensemble=None,
  ):
      feature_columns = [tf.feature_column.numeric_column("x")]
      generator = simple_dnn.Generator(
          feature_columns=feature_columns,
          optimizer=tf.compat.v1.train.GradientDescentOptimizer(0.1),
          layer_size=3,
          initial_num_layers=initial_num_layers,
          learn_mixture_weights=learn_mixture_weights,
          seed=42,
      )
      with context.graph_mode(), tf.Graph().as_default() as g:
          iteration_step = tf.compat.v1.train.create_global_step()
          features = {"x": [[1.0], [2.0]]}
          labels = tf.constant([[0.0], [1.0]])
          names = []
          subnetwork_losses = []
          mixture_weight_losses = []
          complexities = []
          for builder in generator.generate_candidates(
              previous_ensemble,
              # The following arguments are not used by
              # simple_dnn.BuilderGenerator's generate_candidates.
              iteration_number=0,
              previous_ensemble_reports=[],
              all_reports=[],
          ):
              names.append(builder.name)
  
              # 1. Build subnetwork graph.
              subnetwork = builder.build_subnetwork(
                  features,
                  logits_dimension=1,
                  training=True,
                  iteration_step=iteration_step,
                  summary=tf.summary,
                  previous_ensemble=previous_ensemble,
              )
  
              # 2. Build subnetwork train ops.
              subnetwork_loss = tf.reduce_mean(
                  tf.nn.sigmoid_cross_entropy_with_logits(
                      logits=subnetwork.logits, labels=labels
                  )
              )
              subnetwork_train_op = builder.build_subnetwork_train_op(
                  subnetwork,
                  subnetwork_loss,
                  var_list=None,
                  labels=labels,
                  iteration_step=iteration_step,
                  summary=tf.summary,
                  previous_ensemble=None,
              )
  
              # 3. Build mixture weight train ops.
  
              # Stop gradients since mixture weights should have not propagate
              # beyond top layer.
              subnetwork_logits = tf.stop_gradient(subnetwork.logits)
  
              # Mixture weight will initialize to a one-valued scalar.
              mixture_weight_logits = tf.compat.v1.layers.dense(
                  subnetwork_logits,
                  units=1,
                  use_bias=False,
                  kernel_initializer=tf.ones_initializer(),
              )
              mixture_weight_loss = tf.reduce_mean(
                  tf.nn.sigmoid_cross_entropy_with_logits(
                      logits=mixture_weight_logits, labels=labels
                  )
              )
              mixture_weight_train_op = (
                  builder.build_mixture_weights_train_op(
                      mixture_weight_loss,
                      var_list=None,
                      labels=labels,
                      logits=mixture_weight_logits,
                      iteration_step=iteration_step,
                      summary=tf.summary,
                  )
              )
  
              with self.test_session(graph=g) as sess:
                  sess.run(tf.compat.v1.global_variables_initializer())
                  sess.run(subnetwork_train_op)
                  sess.run(mixture_weight_train_op)
                  subnetwork_losses.append(sess.run(subnetwork_loss))
                  mixture_weight_losses.append(
                      sess.run(mixture_weight_loss)
                  )
                  complexities.append(sess.run(subnetwork.complexity))
  
      self.assertEqual(want_names, names)
      self.assertAllClose(
          want_subnetwork_losses, subnetwork_losses, atol=1e-3
      )
      self.assertAllClose(
          want_mixture_weight_losses, mixture_weight_losses, atol=1e-3
      )
      self.assertAllClose(want_complexities, complexities, atol=1e-3)
  
file_path: adanet/adanet/examples/simple_dnn_test.py
imports: from absl.testing import parameterized
  import adanet
  from adanet.examples import simple_dnn
  import tensorflow.compat.v2
  from tensorflow.python.eager import context
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 1 for calling the GeneratorTest obj's underlying member method code with example usage: obj.test_generate_candidates(want_names, want_subnetwork_losses, want_mixture_weight_losses, want_complexities, learn_mixture_weights, initial_num_layers, previous_ensemble) without return types