docstr: Ensures that metrics are only added during evaluation.
  
  Adding metrics during training will break when running on TPU.
  
  Args:
    mode: The mode with which to run the test.
code: def test_only_adds_metrics_when_evaluating(self, mode):
      """Ensures that metrics are only added during evaluation.
  
      Adding metrics during training will break when running on TPU.
  
      Args:
        mode: The mode with which to run the test.
      """
  
      def metric_fn(features):
          return {"mean_x": tf_compat.v1.metrics.mean(features["x"])}
  
      subnetwork_metrics, ensemble_metrics = self._make_metrics(
          metric_fn, mode
      )
  
      self.assertEmpty(subnetwork_metrics)
      self.assertEmpty(ensemble_metrics)
  
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.ensemble_builder import _EnsembleBuilder
  from adanet.core.ensemble_builder import _SubnetworkManager
  from adanet.core.summary import Summary
  import adanet.core.testing_utils
  from adanet.ensemble import Candidate
  from adanet.ensemble import ComplexityRegularizedEnsembler
  from adanet.ensemble import MeanEnsemble
  from adanet.ensemble import MeanEnsembler
  from adanet.ensemble import MixtureWeightType
  from adanet.subnetwork import Builder
  from adanet.subnetwork import Subnetwork
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow.python.eager import context
  from tensorflow.python.framework import test_util
  from tensorflow.python.training import training
  from tensorflow.python.training import training_util
  from tensorflow_estimator.python.estimator.head import binary_class_head
  from tensorflow_estimator.python.estimator.head import multi_head
label_desc: Use image node_id 3 for calling the EnsembleBuilderMetricFnTest obj's underlying member method code with example usage: obj.test_only_adds_metrics_when_evaluating(mode) and returns: dict