<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def flush(table='filter', chain='', family='ipv4'):
    '''
    Flush the chain in the specified table, flush all chains in the specified
    table if chain is not specified.

    CLI Example:

    .. code-block:: bash

        salt '*' nftables.flush filter

        salt '*' nftables.flush filter input

        IPv6:
        salt '*' nftables.flush filter input family=ipv6
    '''
    ret = {'comment': 'Failed to flush rules from chain {0} in table {1}.'.format(chain, table),
           'result': False}

    res = check_table(table, family=family)
    if not res['result']:
        return res

    nft_family = _NFTABLES_FAMILIES[family]

    if chain:
        res = check_chain(table, chain, family=family)
        if not res['result']:
            return res
        cmd = '{0} flush chain {1} {2} {3}'.\
              format(_nftables_cmd(), nft_family, table, chain)
        comment = 'from chain {0} in table {1} in family {2}.'.\
                  format(chain, table, family)
    else:
        cmd = '{0} flush table {1} {2}'.\
                format(_nftables_cmd(), nft_family, table)
        comment = 'from table {0} in family {1}.'.\
                  format(table, family)
    out = __salt__['cmd.run'](cmd, python_shell=False)

    if len(out) == 0:
        ret['result'] = True
        ret['comment'] = 'Flushed rules {0}'.format(comment)
    else:
        ret['comment'] = 'Failed to flush rules {0}'.format(comment)
    return ret