human
Complete this python program:
def ignore_warnings(obj=None, category=Warning):
assistant
#Here is the Python program you requested.

    """Context manager and decorator to ignore warnings.
    Note. Using this (in both variants) will clear all warnings
    from all python modules loaded. In case you need to test
    cross-module-warning-logging this is not your tool of choice.
    Parameters
    category : warning class, defaults to Warning.
    The category to filter. If Warning, all categories will be muted.
    Examples
    >>> with ignore_warnings():
    ...     warnings.warn(\buhuhuhu\)
    >>> def nasty_warn():
    ...    warnings.warn(\buhuhuhu\)
    ...    print(42)
    >>> ignore_warnings(nasty_warn)()
    42
    """
    if callable(obj):
        return _IgnoreWarnings(category=category)(obj)
    else:
        return _IgnoreWarnings(category=category)