'Returns the lengths of the batch of elements in the given dimension.
WARNING: The returned sizes may not exactly match TF\'s calculation.
Args:
dim: dimension to get the sizes of, in [1,2]. batch, depth not allowed.
factor: A scalar value to multiply by.
Returns:
The original heights/widths scaled by the current scaling of the model and
the given factor.
Raises:
ValueError: If the args are invalid.'

def GetLengths(self, dim=2, factor=1):

    if (dim == 1):
        lengths = self.heights
    elif (dim == 2):
        lengths = self.widths
    else:
        raise ValueError('Invalid    dimension    given    to    GetLengths')
    lengths = tf.cast(lengths, tf.float32)
    if (self.reduction_factors[dim] is not None):
        lengths = tf.div(lengths, self.reduction_factors[dim])
    else:
        lengths = tf.ones_like(lengths)
    if (factor != 1):
        lengths = tf.multiply(lengths, tf.cast(factor, tf.float32))
    return tf.cast(lengths, tf.int32)
