def convert_usage(usage, kilobytes=False, megabytes=False):
    """Convert units of memory

    Converts to gigabytes unless the `kilobytes` or `megabytes` argument is
    given.
    
    Parameters
    ----------
    usage : int
        Memory usage in bytes
    kilobytes : bool
        Convert to kilobytes
    megabytes : bool
        Convert to megabytes
    
    Returns
    -------
    int
        Converted value
    """
    return int(usage / 1024 ** (2 - 2 * kilobytes - 1 * megabytes))
