human
Complete this python program:
def elem_is_invisible_with_wait(context, elem, wait_time=MAX_WAIT_TIME):
assistant
#Here is the Python program you requested.

    """Waits for the element to become invisible
    context: a behave context
    elem: a WebDriver element
    wait_time: sets the max wait time. Optional, but has a default value.
    Returns True if the element is invisible or stale, otherwise waits and returns False
    """
    try:
        if (not elem.is_displayed()):
            return True
    except StaleElementReferenceException:
        return True
    def displayed_condition(driver):
        try:
            return (not elem.is_displayed())
        except StaleElementReferenceException:
            return True
    try:
        WebDriverWait(context.browser, wait_time).until(displayed_condition)
        return True
    except TimeoutException:
        return False