<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def colorgen(colors=None, n=None, scale=None, theme=None):
 """ Returns a generator with a list of colors and gradients of those colors Parameters: colors : list(colors) List of colors to use Example: colorgen() colorgen(['blue','red','pink']) colorgen(['#f03','rgb(23,25,25)']) """

    from .themes import THEMES
    step = .1
    if not colors:
        if not scale:
            if not theme:
                scale = get_config_file()['colorscale']
            else:
                scale = THEMES[theme]['colorscale']
        colors = get_scales(scale)
    dq = deque(colors)
    if len(dq) == 0:
        dq = deque(get_scales('ggplot'))
    if n:
        step = len(dq) * 0.8 / n if len(dq) * 8 < n else .1
    for i in np.arange(.2, 1, step):
        for y in dq:
            yield to_rgba(y, 1 - i + .2)
        dq.rotate(1)