<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_colr(txt, argd):
 """ Return a Colr instance based on user args. """

    fore = parse_colr_arg(
        get_name_arg(argd, '--fore', 'FORE', default=None),
        rgb_mode=argd['--truecolor'],
    )
    back = parse_colr_arg(
        get_name_arg(argd, '--back', 'BACK', default=None),
        rgb_mode=argd['--truecolor'],
    )
    style = get_name_arg(argd, '--style', 'STYLE', default=None)
    if argd['--gradient']:
        # Build a gradient from user args.
        return C(txt).gradient(
            name=argd['--gradient'],
            spread=try_int(argd['--spread'], 1, minimum=0),
            fore=fore,
            back=back,
            style=style,
            rgb_mode=argd['--truecolor'],
        )
    if argd['--gradientrgb']:
        # Build an rgb gradient from user args.
        rgb_start, rgb_stop = parse_gradient_rgb_args(argd['--gradientrgb'])
        return C(txt).gradient_rgb(
            fore=fore,
            back=back,
            style=style,
            start=rgb_start,
            stop=rgb_stop,
        )
    if argd['--rainbow']:
        return C(txt).rainbow(
            fore=fore,
            back=back,
            style=style,
            freq=try_float(argd['--frequency'], 0.1, minimum=0),
            offset=try_int(argd['--offset'], randint(0, 255), minimum=0),
            spread=try_float(argd['--spread'], 3.0, minimum=0),
            rgb_mode=argd['--truecolor'],
        )

    # Normal colored output.
    return C(txt, fore=fore, back=back, style=style)