def get_dim_int(tensor, dim):
    """
    Compatability function to get an int shape value for dimension dim of a
    tensor.

    Parameters
    ----------
    tensor : tf.tensor
        The input tensor
    dim : int
        The Dimension who's shape we want to know'

    Returns
    -------
    shape : int
        The shape of dimension dim

    """

    try:
        # this should work only in tensorflow 1
        shape = tensor.get_shape()[dim].value
    except AttributeError:
        # this should work in tensorflow 2
        shape = tensor.get_shape()[dim]
    return shape