"""Your editable exercises. Complete one function, then run check_workshop.py.

Start with absolute_mask. Use only the Python standard library.
The checker prints the first counterexample; it does not overwrite your work.
"""


def absolute_mask(local_row,past,key_length):
    """Return key_length booleans. Query absolute position = past + local_row."""
    raise NotImplementedError('TODO 1: write the absolute causal mask')


def kv_group(query_head,query_heads,kv_heads):
    """Return the contiguous KV group for this Q head; Hq is divisible by Hkv."""
    raise NotImplementedError('TODO 2: map a Q head to its KV group')


def merge_tile(old_max,old_den,old_acc,scores,values):
    """Merge one nonempty tile. Return (new_max, new_den, new_acc).

    old_acc is the UNNORMALIZED weighted sum, not the final output.
    The initial state is (-inf, 0, [0]*value_dimension).
    """
    raise NotImplementedError('TODO 3: rescale both old state and new tile')


def combine(token_count,dimension,routes):
    """routes contains (token_index, gate_weight, expert_output) in any order.

    Return [token_count, dimension], accumulating weighted outputs by token ID.
    Some tokens may receive no route; their output must stay zero.
    """
    raise NotImplementedError('TODO 4: weighted scatter-add back to token order')
