<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def context_id(ctx: Context_T, *, mode: str = 'default', use_hash: bool = False) -> str: """ Calculate a unique id representing the current context. mode: default: one id for one context group: one id for one group or discuss user: one id for one user :param ctx: the context dict :param mode: unique id mode: "default", "group", or "user" :param use_hash: use md5 to hash the id or not """

    ctx_id = ''
    if mode == 'default':
        if ctx.get('group_id'):
            ctx_id = f'/group/{ctx["group_id"]}'
        elif ctx.get('discuss_id'):
            ctx_id = f'/discuss/{ctx["discuss_id"]}'
        if ctx.get('user_id'):
            ctx_id += f'/user/{ctx["user_id"]}'
    elif mode == 'group':
        if ctx.get('group_id'):
            ctx_id = f'/group/{ctx["group_id"]}'
        elif ctx.get('discuss_id'):
            ctx_id = f'/discuss/{ctx["discuss_id"]}'
        elif ctx.get('user_id'):
            ctx_id = f'/user/{ctx["user_id"]}'
    elif mode == 'user':
        if ctx.get('user_id'):
            ctx_id = f'/user/{ctx["user_id"]}'

    if ctx_id and use_hash:
        ctx_id = hashlib.md5(ctx_id.encode('ascii')).hexdigest()
    return ctx_id