def layer_op(self, image, conditioning, is_training):
    batch_size = image.shape.as_list()[0]

    def down(ch, x):
        with tf.name_scope('downsample'):
            conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=3, stride=2, feature_normalization='batch', acti_func='selu', w_initializer=self.initializers['w'])
            return conv_layer(x, is_training=is_training)

    def convr(ch, x):
        conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=3, feature_normalization='batch', acti_func='selu', w_initializer=self.initializers['w'])
        return conv_layer(x, is_training=is_training)

    def conv(ch, x, s):
        conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=3, feature_normalization='batch', w_initializer=self.initializers['w'])
        acti_layer = ActiLayer(func='selu')
        res_flow = (conv_layer(x, is_training=is_training) + s)
        return acti_layer(res_flow)

    def down_block(ch, x):
        with tf.name_scope('down_resnet'):
            s = down(ch, x)
            r = convr(ch, s)
            return conv(ch, r, s)

    def feature_block(ch, image):
        with tf.name_scope('feature'):
            conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=5, with_bias=True, feature_normalization=None, acti_func='selu', w_initializer=self.initializers['w'], b_initializer=self.initializers['b'])
            d_h1s = conv_layer(image, is_training=is_training)
            d_h1r = convr(ch, d_h1s)
            return conv(ch, d_h1r, d_h1s)

    def fully_connected(ch, features):
        with tf.name_scope('fully_connected'):
            fc_layer = FullyConnectedLayer(n_output_chns=ch, feature_normalization=None, with_bias=True)
            return fc_layer(features, is_training=is_training)
    if (conditioning is not None):
        image = tf.concat([image, conditioning], axis=(- 1))
    flow = image
    for (idx, n_chns) in enumerate(self.chns):
        if (idx == 0):
            flow = feature_block(n_chns, flow)
        elif (idx == (len(self.chns) - 1)):
            return fully_connected(n_chns, flow)
        else:
            flow = down_block(n_chns, flow)
def layer_op(self, image, conditioning, is_training):
    batch_size = image.shape.as_list()[0]

    def down(ch, x):
        with tf.name_scope('downsample'):
            conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=3, stride=2, feature_normalization='batch', acti_func='selu', w_initializer=self.initializers['w'])
            return conv_layer(x, is_training=is_training)

    def convr(ch, x):
        conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=3, feature_normalization='batch', acti_func='selu', w_initializer=self.initializers['w'])
        return conv_layer(x, is_training=is_training)

    def conv(ch, x, s):
        conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=3, feature_normalization='batch', w_initializer=self.initializers['w'])
        acti_layer = ActiLayer(func='selu')
        res_flow = (conv_layer(x, is_training=is_training) + s)
        return acti_layer(res_flow)

    def down_block(ch, x):
        with tf.name_scope('down_resnet'):
            s = down(ch, x)
            r = convr(ch, s)
            return conv(ch, r, s)

    def feature_block(ch, image):
        with tf.name_scope('feature'):
            conv_layer = ConvolutionalLayer(n_output_chns=ch, kernel_size=5, with_bias=True, feature_normalization=None, acti_func='selu', w_initializer=self.initializers['w'], b_initializer=self.initializers['b'])
            d_h1s = conv_layer(image, is_training=is_training)
            d_h1r = convr(ch, d_h1s)
            return conv(ch, d_h1r, d_h1s)

    def fully_connected(ch, features):
        with tf.name_scope('fully_connected'):
            fc_layer = FullyConnectedLayer(n_output_chns=ch, feature_normalization=None, with_bias=True)
            return fc_layer(features, is_training=is_training)
    if (conditioning is not None):
        image = tf.concat([image, conditioning], axis=(- 1))
    flow = image
    for (idx, n_chns) in enumerate(self.chns):
        if (idx == 0):
            flow = feature_block(n_chns, flow)
        elif (idx == (len(self.chns) - 1)):
            return fully_connected(n_chns, flow)
        else:
            flow = down_block(n_chns, flow)