human
Complete this python program:
def ignore_errors(conn, fun=None, *args, **kwargs):
assistant
#Here is the Python code you requested.

    """Ignore connection and channel errors.
    The first argument must be a connection object, or any other object
    with ``connection_error`` and ``channel_error`` attributes.
    Can be used as a function:
    .. code-block:: python
    def example(connection):
    ignore_errors(connection, consumer.channel.close)
    or as a context manager:
    .. code-block:: python
    def example(connection):
    with ignore_errors(connection):
    consumer.channel.close()
    Note:
    Connection and channel errors should be properly handled,
    and not ignored.  Using this function is only acceptable in a cleanup
    phase, like when a connection is lost or at shutdown.
    """
    if fun:
        with _ignore_errors(conn):
            return fun(*args, **kwargs)
    return _ignore_errors(conn)