code: def test_build_ensemble(
      self,
      mixture_weight_type=ensemble.MixtureWeightType.SCALAR,
      mixture_weight_initializer=None,
      warm_start_mixture_weights=False,
      adanet_lambda=0.0,
      adanet_beta=0.0,
      multi_head=None,
      use_bias=False,
      num_subnetworks=1,
      num_previous_ensemble_subnetworks=0,
      expected_complexity_regularization=0.0,
      expected_summary_scalars=None,
      name=None,
  ):
      with context.graph_mode():
          model_dir = None
          if warm_start_mixture_weights:
              model_dir = "fake_checkpoint_dir"
          ensembler = ensemble.ComplexityRegularizedEnsembler(
              optimizer=self._optimizer,
              mixture_weight_type=mixture_weight_type,
              mixture_weight_initializer=mixture_weight_initializer,
              warm_start_mixture_weights=warm_start_mixture_weights,
              model_dir=model_dir,
              adanet_lambda=adanet_lambda,
              adanet_beta=adanet_beta,
              use_bias=use_bias,
              name=name,
          )
  
          if name:
              self.assertEqual(ensembler.name, name)
          else:
              self.assertEqual(ensembler.name, "complexity_regularized")
  
          with tf_compat.v1.variable_scope(
              "dummy_adanet_scope_iteration_0"
          ):
              previous_ensemble_subnetworks_all = [
                  self._build_subnetwork(multi_head),
                  self._build_subnetwork(multi_head),
              ]
  
              previous_ensemble = self._build_easy_ensemble(
                  previous_ensemble_subnetworks_all
              )
  
          with tf_compat.v1.variable_scope(
              "dummy_adanet_scope_iteration_1"
          ):
              subnetworks_pool = [
                  self._build_subnetwork(multi_head),
                  self._build_subnetwork(multi_head),
              ]
  
              subnetworks = subnetworks_pool[:num_subnetworks]
  
              previous_ensemble_subnetworks = (
                  previous_ensemble_subnetworks_all[
                      :(num_previous_ensemble_subnetworks)
                  ]
              )
  
              self.summary.clear_scalars()
  
              built_ensemble = ensembler.build_ensemble(
                  subnetworks=subnetworks,
                  previous_ensemble_subnetworks=previous_ensemble_subnetworks,
                  features=None,
                  labels=None,
                  logits_dimension=None,
                  training=None,
                  iteration_step=None,
                  summary=self.summary,
                  previous_ensemble=previous_ensemble,
                  previous_iteration_checkpoint=_FakeCheckpoint(),
              )
  
              with self.test_session() as sess:
                  sess.run(tf_compat.v1.global_variables_initializer())
  
                  summary_scalars, complexity_regularization = sess.run(
                      (
                          self.summary.scalars,
                          built_ensemble.complexity_regularization,
                      )
                  )
  
                  if expected_summary_scalars:
                      for key in expected_summary_scalars.keys():
                          print(summary_scalars)
                          self.assertAllClose(
                              expected_summary_scalars[key],
                              summary_scalars[key],
                          )
  
                  self.assertEqual(
                      [
                          l.subnetwork
                          for l in built_ensemble.weighted_subnetworks
                      ],
                      previous_ensemble_subnetworks + subnetworks,
                  )
  
                  self.assertAllClose(
                      expected_complexity_regularization,
                      complexity_regularization,
                  )
                  self.assertIsNotNone(sess.run(built_ensemble.logits))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import contextlib
  from absl.testing import parameterized
  from adanet import ensemble
  from adanet import subnetwork
  from adanet import tf_compat
  from adanet.core.summary import Summary
  import mock
  import tensorflow.compat.v2
  from tensorflow.python.eager import context
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 4 for calling the ComplexityRegularizedEnsemblerTest obj's underlying member method code with example usage: obj.test_build_ensemble(mixture_weight_type, mixture_weight_initializer, warm_start_mixture_weights, adanet_lambda, adanet_beta, multi_head, use_bias, num_subnetworks, num_previous_ensemble_subnetworks, expected_complexity_regularization, expected_summary_scalars, name) without return types