<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_data(raw_data, limit_per_url_group=LIMIT_PER_URL_GROUP, limit_url_groups=LIMIT_URL_GROUPS):
 """Fomat data from LogAnalyzer for render purpose"""

    data = copy.deepcopy(raw_data)
    for k, v in list(data['data_details'].items()):
        # Only reserve first ``limit_per_url_group`` items
        v['urls'] = sorted(list(v['urls'].items()), key=lambda k_v: k_v[1].total,
                           reverse=True)[:limit_per_url_group]

    data_details = sorted(iter(data['data_details'].items()),
                          key=lambda k_v1: k_v1[1]["duration_agr_data"].total, 
                          reverse=True)[:limit_url_groups]

    if data['requests_counter']['normal']:
        slow_rate = format(data['requests_counter']['slow'] / \
                           float(data['requests_counter']['normal']), '.2%')
    else:
        slow_rate = '-'
    data.update({
        'slow_rate': slow_rate,
        'data_details': data_details,
    })
    return data