<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mkdir(dirs, user=None, group=None, mode=None, use_sudo=True):
 """Create directory with sudo and octal mode, then set ownership."""

    if isinstance(dirs, basestring):
        dirs = [dirs]
    runner = sudo if use_sudo else run
    if dirs:
        modearg = '-m {:o}'.format(mode) if mode else ''
        cmd = 'mkdir -v -p {} {}'.format(modearg, ' '.join(dirs))
        result = runner(cmd)
        with hide('commands'):
            chown(dirs, user, group)
        return result