'Reshapes the input tensor by moving each (x_scale,y_scale) rectangle to.
the depth dimension. NOTE that the TF convention is that inputs are
[batch, y, x, depth].
Args:
prev_layer: Input tensor.
index:      Position in model_str to start parsing
Returns:
Output tensor, end index in model_str.'

def AddReShape(self, prev_layer, index):

    pattern = re.compile('(S)(?:{(\\w)})?(\\d+)\\((\\d+)x(\\d+)\\)(\\d+),(\\d+)')
    m = pattern.match(self.model_str, index)
    if (m is None):
        return (None, None)
    name = self._GetLayerName(m.group(0), index, m.group(2))
    src_dim = int(m.group(3))
    part_a = int(m.group(4))
    part_b = int(m.group(5))
    dest_dim_a = int(m.group(6))
    dest_dim_b = int(m.group(7))
    if (part_a == 0):
        part_a = (-1)
    if (part_b == 0):
        part_b = (-1)
    prev_shape = tf.shape(prev_layer)
    layer = shapes.transposing_reshape(prev_layer, src_dim, part_a, part_b, dest_dim_a, dest_dim_b, name=name)
    result_shape = tf.shape(layer)
    for i in xrange(len(self.reduction_factors)):
        if (self.reduction_factors[i] is not None):
            factor1 = tf.cast(self.reduction_factors[i], tf.float32)
            factor2 = tf.cast(prev_shape[i], tf.float32)
            divisor = tf.cast(result_shape[i], tf.float32)
            self.reduction_factors[i] = tf.div(tf.multiply(factor1, factor2), divisor)
    return (layer, m.end())
