<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_meter(n, total, elapsed, ncols=None, prefix='', unit=None, unit_scale=False, ascii=False):
 """ Return a string-based progress bar given some parameters Parameters n : int Number of finished iterations. total : int The expected total number of iterations. If None, only basic progress statistics are displayed (no ETA). elapsed : float Number of seconds passed since start. ncols : int, optional The width of the entire output message. If sepcified, dynamically resizes the progress meter [default: None]. The fallback meter width is 10. prefix : str, optional Prefix message (included in total width). unit : str, optional String that will be used to define the unit of each iteration. [default: "it"] unit_scale : bool, optional If set, the number of iterations will be reduced/scaled automatically and a metric prefix following the International System of Units standard will be added (kilo, mega, etc.). [default: False] ascii : bool, optional If not set, use unicode (smooth blocks) to fill the meter [default: False]. The fallback is to use ASCII characters (1-9 #). Returns ------- out : Formatted meter and stats, ready to display. """


    # in case the total is wrong (n is above the total), then
    # we switch to the mode without showing the total prediction
    # (since ETA would be wrong anyway)
    if total and n > total:
        total = None

    elapsed_str = format_interval(elapsed)
    if elapsed:
        if unit_scale:
            rate = format_sizeof(n / elapsed, suffix='')
        else:
            rate = '{0:5.2f}'.format(n / elapsed)
    else:
        rate = '?'

    rate_unit = unit if unit else 'it'
    if not unit:
        unit = ''

    n_fmt = str(n)
    total_fmt = str(total)
    if unit_scale:
        n_fmt = format_sizeof(n, suffix='')
        if total:
            total_fmt = format_sizeof(total, suffix='')

    if total:
        frac = n / total
        percentage = frac * 100

        remaining_str = format_interval(elapsed * (total-n) / n) if n else '?'

        l_bar = '{1}{0:.0f}%|'.format(percentage, prefix) if prefix else \
                '{0:3.0f}%|'.format(percentage)
        r_bar = '| {0}/{1}{2} [{3}<{4}, {5} {6}/s]'.format(
                n_fmt, total_fmt, unit, elapsed_str, remaining_str,
                rate, rate_unit)

        if ncols == 0:
            bar = ''
        else:
            N_BARS = max(1, ncols - len(l_bar) - len(r_bar)) if ncols \
                             else 10

            if ascii:
                bar_length, frac_bar_length = divmod(
                    int(frac * N_BARS * 10), 10)

                bar = '#'*bar_length
                frac_bar = chr(48 + frac_bar_length) if frac_bar_length \
                                else ' '

            else:
                bar_length, frac_bar_length = divmod(int(frac * N_BARS * 8), 8)

                bar = _unich(0x2588)*bar_length
                frac_bar = _unich(0x2590 - frac_bar_length) \
                    if frac_bar_length else ' '

        if bar_length < N_BARS:
            full_bar = bar + frac_bar + \
                ' ' * max(N_BARS - bar_length - 1, 0)  # spacing
        else:
            full_bar = bar + \
                ' ' * max(N_BARS - bar_length, 0)  # spacing

        return l_bar + full_bar + r_bar

    else:  # no progressbar nor ETA, just progress statistics
        return '{0}{1} [{2}, {3} {4}/s]'.format(
            n_fmt, unit, elapsed_str, rate, rate_unit)