<commit_before>"""Batch Normalization for TensorFlow.
<NAME>, Jan 2016.
"""

import tensorflow as tf
from tensorflow.python import control_flow_ops


def batch_norm(x, phase_train, name='bn', decay=0.99, reuse=None, affine=True):
    """
    Batch normalization on convolutional maps.
    from: https://stackoverflow.com/questions/33949786/how-could-i-
    use-batch-normalization-in-tensorflow
    Only modified to infer shape from input tensor x.
    Parameters
    ----------
    x
        Tensor, 4D BHWD input maps
    phase_train
        boolean tf.Variable, true indicates training phase
    name
        string, variable name
    affine
        whether to affine-transform outputs
    Return
    ------
    normed
        batch-normalized maps
    """
    with tf.variable_scope(name, reuse=reuse):
        og_shape = x.get_shape().as_list()
        if len(og_shape) == 2:
            x = tf.reshape(x, [-1, 1, 1, og_shape[1]])
        shape = x.get_shape().as_list()
        beta = tf.get_variable(name='beta', shape=[shape[-1]],<commit_msg>Fix missing control_flow_ops import error<commit_after>"""Batch Normalization for TensorFlow.
<NAME>, Jan 2016.
"""

import tensorflow as tf
from tensorflow.python.ops import control_flow_ops


def batch_norm(x, phase_train, name='bn', decay=0.99, reuse=None, affine=True):
    """
    Batch normalization on convolutional maps.
    from: https://stackoverflow.com/questions/33949786/how-could-i-
    use-batch-normalization-in-tensorflow
    Only modified to infer shape from input tensor x.
    Parameters
    ----------
    x
        Tensor, 4D BHWD input maps
    phase_train
        boolean tf.Variable, true indicates training phase
    name
        string, variable name
    affine
        whether to affine-transform outputs
    Return
    ------
    normed
        batch-normalized maps
    """
    with tf.variable_scope(name, reuse=reuse):
        og_shape = x.get_shape().as_list()
        if len(og_shape) == 2:
            x = tf.reshape(x, [-1, 1, 1, og_shape[1]])
        shape = x.get_shape().as_list()
        beta = tf.get_variable(name='beta', shape=[shape[-1]],
{'fraction_non_alphanumeric': 0.11960600375234522, 'fraction_numerical': 0.020637898686679174, 'mean_word_length': 2.6152542372881356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1853702', 'n_tokens_mistral': 685, 'n_tokens_neox': 638, 'n_words': 173}