human
Complete this python program:
def ResNet_FullPreActivation(input_var=None, n=18):
assistant
#Here is the Python program you requested.

    """Adapted from https://github.com/Lasagne/Recipes/tree/master/papers/deep_residual_learning.
    Tweaked to be consistent with \Identity Mappings in Deep Residual Networks\, Kaiming He et al. 2016 (https://arxiv.org/abs/1603.05027)
    Forumala to figure out depth: 6n + 2
    """
    def residual_block(l, increase_dim=False, projection=True, first=False):
        input_num_filters = l.output_shape[1]
        if increase_dim:
            first_stride = (2, 2)
            out_num_filters = (input_num_filters * 2)
        else:
            first_stride = (1, 1)
            out_num_filters = input_num_filters
        if first:
            bn_pre_relu = l
        else:
            bn_pre_conv = BatchNormLayer(l)
            bn_pre_relu = NonlinearityLayer(bn_pre_conv, rectify)
        conv_1 = batch_norm(ConvLayer(bn_pre_relu, num_filters=out_num_filters, filter_size=(3, 3), stride=first_stride, nonlinearity=rectify, pad='same', W=he_norm))
        conv_2 = ConvLayer(conv_1, num_filters=out_num_filters, filter_size=(3, 3), stride=(1, 1), nonlinearity=None, pad='same', W=he_norm)
        if increase_dim:
            projection = ConvLayer(l, num_filters=out_num_filters, filter_size=(1, 1), stride=(2, 2), nonlinearity=None, pad='same', b=None)
            block = ElemwiseSumLayer([conv_2, projection])
        else:
            block = ElemwiseSumLayer([conv_2, l])
        return block
    l_in = InputLayer(shape=(None, 3, PIXELS, PIXELS), input_var=input_var)
    l = batch_norm(ConvLayer(l_in, num_filters=16, filter_size=(3, 3), stride=(1, 1), nonlinearity=rectify, pad='same', W=he_norm))
    l = residual_block(l, first=True)
    for _ in range(1, n):
        l = residual_block(l)
    l = residual_block(l, increase_dim=True)
    for _ in range(1, n):
        l = residual_block(l)
    l = residual_block(l, increase_dim=True)
    for _ in range(1, n):
        l = residual_block(l)
    bn_post_conv = BatchNormLayer(l)
    bn_post_relu = NonlinearityLayer(bn_post_conv, rectify)
    avg_pool = GlobalPoolLayer(bn_post_relu)
    network = DenseLayer(avg_pool, num_units=10, W=HeNormal(), nonlinearity=softmax)
    return network