human
Solve the following python programming problem given the following code:
@inspect_command(alias=u'dump_tasks', variadic=u'taskinfoitems', signature=u'[attr1    [attr2    [...    [attrN]]]]')
def registered(state, taskinfoitems=None, builtins=False, **kwargs):
assistant
#Here is the Python program you requested.

    """List of registered tasks.
    Arguments:
    taskinfoitems (Sequence[str]): List of task attributes to include.
    Defaults to ``exchange,routing_key,rate_limit``.
    builtins (bool): Also include built-in tasks.
    """
    reg = state.app.tasks
    taskinfoitems = (taskinfoitems or DEFAULT_TASK_INFO_ITEMS)
    tasks = (reg if builtins else (task for task in reg if (not task.startswith(u'celery.'))))
    def _extract_info(task):
        fields = {field: str(getattr(task, field, None)) for field in taskinfoitems if (getattr(task, field, None) is not None)}
        if fields:
            info = [u'='.join(f) for f in items(fields)]
            return u'{0}    [{1}]'.format(task.name, u'    '.join(info))
        return task.name
    return [_extract_info(reg[task]) for task in sorted(tasks)]