<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _prepare_colors(color, values, limits_c, colormap, alpha, chan=None):
 """Return colors for all the channels based on various inputs. Parameters color : tuple 3-, 4-element tuple, representing RGB and alpha, between 0 and 1 values : ndarray array with values for each channel limits_c : tuple of 2 floats, optional min and max values to normalize the color colormap : str one of the colormaps in vispy alpha : float transparency (0 = transparent, 1 = opaque) chan : instance of Channels use labels to create channel groups Returns ------- 1d / 2d array colors for all the channels or for each channel individually tuple of two float or None limits for the values """

    if values is not None:
        if limits_c is None:
            limits_c = array([-1, 1]) * nanmax(abs(values))

        norm_values = normalize(values, *limits_c)

        cm = get_colormap(colormap)
        colors = cm[norm_values]

    elif color is not None:
        colors = ColorArray(color)

    else:
        cm = get_colormap('hsl')
        group_idx = _chan_groups_to_index(chan)
        colors = cm[group_idx]

    if alpha is not None:
        colors.alpha = alpha

    return colors, limits_c