import tensorflow as tf

            aux = deconv2d(activation(aux), [dim[0], dim[1], [in_shp[1] // aux_shp[1], in_shp[2] // aux_shp[2]]],
                        scope="%s_conv_upsample_aux" % scope, training=training, ema=ema, init=init)
        else:
            aux = nin(activation(aux), dim[0], training=training, ema=ema, init=init, scope="%s_conv_aux" % scope)

        out += aux

    out = activation(out)

    if dropout > 0:
        out = tf.layers.dropout(out, rate=dropout, training=training)

    out = conv(out, [2*dim[0], dim[1], dim[2]], scope="%s_conv_out"%scope, training=training, ema=ema, init=init)
    h_stack1, h_stack2 = tf.split(out, 2, 3)
    sigmoid_out = tf.sigmoid(h_stack2)
    out = (h_stack1 * sigmoid_out)

    out_shp = out.get_shape().as_list()
    if out_shp[1:-1] < in_shp[1:-1]:
        x = tf.nn.avg_pool(x, [1, dim[2][0], dim[2][1], 1], strides=[1, dim[2][0], dim[2][1], 1], padding='SAME')
