import tensorflow as tf

        if bias:
            b = bias_variable([shape[-2]])
            h = h + b
        return h

def phase_shift_3d(x, r):
    batch_size, d, h, w, c = x.get_shape().as_list()
    x = tf.reshape(x, (batch_size, d, h, w, r, r, r))
    for ns in [d, h, w]:
        x = tf.split(x, ns, 1)
        x = tf.concat([tf.squeeze(v, 1) for v in x], 3)
    return tf.reshape(x, (batch_size, d*r, h*r, w*r, 1))

def subpixel_conv3d(x, r, out_channels):
    x = tf.split(x, out_channels, 4)
    x = tf.concat([phase_shift_3d(v, r) for v in x], 4)
    return x

def pixel_shuffler_3d(x, r, k, out_channels, name):
    in_channels = x.get_shape.as_list()[4]
