<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_flashed_messages( with_categories: bool=False, category_filter: List[str]=[], ) -> Union[List[str], List[Tuple[str, str]]]: """Retrieve the flashed messages stored in the session. This is mostly useful in templates where it is exposed as a global function, for example .. code-block:: html+jinja <ul> {% for message in get_flashed_messages() %} <li>{{ message }}</li> {% endfor %} </ul> Note that caution is required for usage of ``category_filter`` as all messages will be popped, but only those matching the filter returned. See :func:`~quart.helpers.flash` for message creation. """

    flashes = session.pop('_flashes') if '_flashes' in session else []
    if category_filter:
        flashes = [flash for flash in flashes if flash[0] in category_filter]
    if not with_categories:
        flashes = [flash[1] for flash in flashes]
    return flashes