code: def get_bn_variables(
      n_out, use_scale, use_bias, beta_init, gamma_init
  ):
      if use_bias:
          beta = tf.get_variable("beta", [n_out], initializer=beta_init)
      else:
          beta = tf.zeros([n_out], name="beta")
      if use_scale:
          gamma = tf.get_variable(
              "gamma", [n_out], initializer=gamma_init
          )
      else:
          gamma = tf.ones([n_out], name="gamma")
      # x * gamma + beta
  
      moving_mean = tf.get_variable(
          "mean/EMA",
          [n_out],
          initializer=tf.constant_initializer(),
          trainable=False,
      )
      moving_var = tf.get_variable(
          "variance/EMA",
          [n_out],
          initializer=tf.constant_initializer(1.0),
          trainable=False,
      )
  
      if get_current_tower_context().is_main_training_tower:
          for v in [moving_mean, moving_var]:
              tf.add_to_collection(tf.GraphKeys.MODEL_VARIABLES, v)
      return beta, gamma, moving_mean, moving_var
  
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 1 for calling a global function with example usage: get_bn_variables(n_out, use_scale, use_bias, beta_init, gamma_init) and returns: beta,  gamma,  moving_mean,  moving_var