<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_scales(scale=None, n=None):
 """ Returns a color scale Parameters: scale : str Color scale name If the color name is preceded by a minus (-) then the scale is inversed n : int Number of colors If n < number of colors available for a given scale then the minimum number will be returned If n > number of colors available for a given scale then the maximum number will be returned Example: get_scales('accent',8) get_scales('pastel1') """

    if scale:
        is_reverse = False
        if scale[0] == '-':
            scale = scale[1:]
            is_reverse = True
        d = copy.deepcopy(_scales_names[scale.lower()])
        keys = list(map(int, list(d.keys())))
        cs = None
        if n:
            if n in keys:
                cs = d[str(n)]
            elif n < min(keys):
                cs = d[str(min(keys))]
        if cs is None:
            cs = d[str(max(keys))]
        if is_reverse:
            cs.reverse()
        return cs
    else:
        d = {}
        for k, v in list(_scales_names.items()):
            if isinstance(v, dict):
                keys = list(map(int, list(v.keys())))
                d[k] = v[str(max(keys))]
            else:
                d[k] = v
        return d