def get_spatial_dim(tensor):
    """ Return spatial dim of the input tensor (without channels and batch dimension).

    Parameters
    ----------
    tensor : tf.Tensor

    Returns
    -------
    dim : int
    """
    return len(tensor.get_shape().as_list()) - 2