<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def switch( confs=None, remain=False, all_checked=False, _default=None, **kwargs ):
 """ Execute first statement among conf where task result is True. If remain, process all statements conf starting from the first checked conf. :param confs: task confs to check. Each one may contain a task action at the key 'action' in conf. :type confs: str or dict or list :param bool remain: if True, execute all remaining actions after the first checked condition. :param bool all_checked: execute all statements where conditions are checked. :param _default: default task to process if others have not been checked. :type _default: str or dict :return: statement result or list of statement results if remain. :rtype: list or object """


    # init result
    result = [] if remain else None

        # check if remain and one task has already been checked.
    remaining = False

    if confs is not None:
        if isinstance(confs, string_types) or isinstance(confs, dict):
            confs = [confs]

        for conf in confs:
            # check if task has to be checked or not
            check = remaining

            if not check:
                # try to check current conf
                check = run(conf=conf, **kwargs)

            # if task is checked or remaining
            if check:

                if STATEMENT in conf:  # if statements exist, run them
                    statement = conf[STATEMENT]
                    statement_result = run(statement, **kwargs)

                    # save result
                    if not remain:  # if not remain, result is statement_result
                        result = statement_result

                    else:  # else, add statement_result to result
                        result.append(statement_result)

                # if remain
                if remain:
                    # change of remaining status
                    if not remaining:
                        remaining = True

                elif all_checked:
                    pass

                else:  # leave execution if one statement has been executed
                    break

    # process _default statement if necessary
    if _default is not None and (remaining or (not result) or all_checked):
        last_result = run(_default, **kwargs)

        if not remain:
            result = last_result

        else:
            result.append(last_result)

    return result