code: def test_build_candidate(self, training, want_adanet_losses):
      # `Cadidate#build_candidate` will only ever be called in graph mode.
      with context.graph_mode():
          # A fake adanet_loss that halves at each train step: 1.0, 0.5, 0.25, ...
          fake_adanet_loss = tf.Variable(1.0)
          fake_train_op = fake_adanet_loss.assign(fake_adanet_loss / 2)
          fake_ensemble_spec = tu.dummy_ensemble_spec(
              "new",
              adanet_loss=fake_adanet_loss,
              train_op=fake_train_op,
          )
  
          builder = _CandidateBuilder()
          candidate = builder.build_candidate(
              ensemble_spec=fake_ensemble_spec,
              training=training,
              summary=_FakeSummary(),
          )
          self.evaluate(tf_compat.v1.global_variables_initializer())
          adanet_losses = []
          for _ in range(len(want_adanet_losses)):
              adanet_loss = self.evaluate(candidate.adanet_loss)
              adanet_losses.append(adanet_loss)
              self.evaluate(fake_train_op)
  
          # Verify that adanet_loss moving average works.
          self.assertAllClose(
              want_adanet_losses, adanet_losses, atol=1e-3
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  from absl.testing import parameterized
  from adanet import tf_compat
  from adanet.core.candidate import _Candidate
  from adanet.core.candidate import _CandidateBuilder
  import adanet.core.testing_utils
  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 CandidateBuilderTest obj's underlying member method code with example usage: obj.test_build_candidate(training, want_adanet_losses) without return types