code: def internal_update_bn_ema(
      xn, batch_mean, batch_var, moving_mean, moving_var, decay
  ):
      update_op1 = moving_averages.assign_moving_average(
          moving_mean,
          batch_mean,
          decay,
          zero_debias=False,
          name="mean_ema_op",
      )
      update_op2 = moving_averages.assign_moving_average(
          moving_var,
          batch_var,
          decay,
          zero_debias=False,
          name="var_ema_op",
      )
  
      # When sync_statistics is True, always enable internal_update.
      # Otherwise the update ops (only executed on main tower)
      # will hang when some BatchNorm layers are unused (https://github.com/tensorpack/tensorpack/issues/1078)
      with tf.control_dependencies([update_op1, update_op2]):
          return tf.identity(xn, name="output")
  
file_path: tensorpack/tensorpack/models/batch_norm.py
imports: import re
  from ..compat import tfv1
  from tensorflow.python.training import moving_averages
  from ..tfutils.collection import backup_collection, restore_collection
  from ..tfutils.common import get_tf_version_tuple
  from ..tfutils.tower import get_current_tower_context
  from ..utils import logger
  from ..utils.argtools import get_data_format, log_once
  from .common import VariableHolder, layer_register
  from .tflayer import convert_to_tflayer_args, rename_get_variable
  from .utils import disable_autograph
label_desc: Use image node_id 2 for calling a global function with example usage: internal_update_bn_ema(xn, batch_mean, batch_var, moving_mean, moving_var, decay) and returns: tf