code: def batch_normalization(
      incoming,
      beta=0.0,
      gamma=1.0,
      epsilon=1e-5,
      decay=0.9,
      stddev=0.002,
      trainable=True,
      restore=True,
      reuse=False,
      scope=None,
      name="BatchNormalization",
  ):
      """Batch Normalization.
  
      Normalize activations of the previous layer at each batch.
  
      Arguments:
          incoming: `Tensor`. Incoming Tensor.
          beta: `float`. Default: 0.0.
          gamma: `float`. Default: 1.0.
          epsilon: `float`. Defalut: 1e-5.
          decay: `float`. Default: 0.9.
          stddev: `float`. Standard deviation for weights initialization.
          trainable: `bool`. If True, weights will be trainable.
          restore: `bool`. If True, this layer weights will be restored when
              loading a model.
          reuse: `bool`. If True and 'scope' is provided, this layer variables
              will be reused (shared).
          scope: `str`. Define this layer scope (optional). A scope can be
              used to share variables between layers. Note that scope will
              override name.
          name: `str`. A name for this layer (optional).
  
      References:
          Batch Normalization: Accelerating Deep Network Training by Reducing
          Internal Covariate Shif. Sergey Ioffe, Christian Szegedy. 2015.
  
      Links:
          [http://arxiv.org/pdf/1502.03167v3.pdf](http://arxiv.org/pdf/1502.03167v3.pdf)
  
      """
  
      input_shape = utils.get_incoming_shape(incoming)
      input_ndim = len(input_shape)
  
      gamma_init = tf.random_normal_initializer(
          mean=gamma, stddev=stddev
      )
  
      with tf.variable_scope(
          scope, default_name=name, values=[incoming], reuse=reuse
      ) as scope:
          name = scope.name
          beta = vs.variable(
              "beta",
              shape=[input_shape[-1]],
              initializer=tf.constant_initializer(beta),
              trainable=trainable,
              restore=restore,
          )
          gamma = vs.variable(
              "gamma",
              shape=[input_shape[-1]],
              initializer=gamma_init,
              trainable=trainable,
              restore=restore,
          )
          # Track per layer variables
          tf.add_to_collection(
              tf.GraphKeys.LAYER_VARIABLES + "/" + name, beta
          )
          tf.add_to_collection(
              tf.GraphKeys.LAYER_VARIABLES + "/" + name, gamma
          )
          if not restore:
              tf.add_to_collection(tf.GraphKeys.EXCL_RESTORE_VARS, beta)
              tf.add_to_collection(
                  tf.GraphKeys.EXCL_RESTORE_VARS, gamma
              )
  
          axis = list(range(input_ndim - 1))
  
          moving_mean = vs.variable(
              "moving_mean",
              input_shape[-1:],
              initializer=tf.zeros_initializer(),
              trainable=False,
              restore=restore,
          )
          moving_variance = vs.variable(
              "moving_variance",
              input_shape[-1:],
              initializer=tf.constant_initializer(1.0),
              trainable=False,
              restore=restore,
          )
  
          # Define a function to update mean and variance
          def update_mean_var():
              mean, variance = tf.nn.moments(incoming, axis)
  
              update_moving_mean = (
                  moving_averages.assign_moving_average(
                      moving_mean, mean, decay, zero_debias=False
                  )
              )
              update_moving_variance = (
                  moving_averages.assign_moving_average(
                      moving_variance,
                      variance,
                      decay,
                      zero_debias=False,
                  )
              )
  
              with tf.control_dependencies(
                  [update_moving_mean, update_moving_variance]
              ):
                  return tf.identity(mean), tf.identity(variance)
  
          # Retrieve variable managing training mode
          is_training = tflearn.get_training_mode()
          mean, var = tf.cond(
              is_training,
              update_mean_var,
              lambda: (moving_mean, moving_variance),
          )
  
          inference = tf.nn.batch_normalization(
              incoming, mean, var, beta, gamma, epsilon
          )
          inference.set_shape(input_shape)
  
      # Add attributes for easy access
      inference.scope = scope
      inference.beta = beta
      inference.gamma = gamma
  
      # Track output tensor.
      tf.add_to_collection(
          tf.GraphKeys.LAYER_TENSOR + "/" + name, inference
      )
  
      return inference
  
file_path: tflearn/tflearn/layers/normalization.py
imports: from __future__ import division, print_function, absolute_import
  import tensorflow.compat.v1
  from tensorflow.python.training import moving_averages
  import tflearn
  from ..None import utils
  from ..None import variables
  from ..utils import get_from_module
label_desc: Use image node_id 2 for calling a global function with example usage: batch_normalization(incoming, beta, gamma, epsilon, decay, stddev, trainable, restore, reuse, scope, name) and returns: inference, tf,  tf