Read the equation
In KimiK25ForConditionalGeneration.forward, this statement defines or updates (batch_index, non_attended_tokens). The reduction aggregates values along the explicit source axis; preserving the axis and keep-dimension setting matters for the later broadcast.
Terms & definitions
The recovered passage does not supply a separate symbol table. Read the source context for the notation used in this version; familiar letters may carry different meanings in other builds.
How it works
Read batch_index, non_attended_tokens as the quantity being defined or updated by this relation.
Substitute the source-defined variables or recorded values and follow the displayed arithmetic and indexing exactly.
Use this version’s variable definitions and update order. The same symbol may be assigned a different meaning in another build.
Assumptions & limits
Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.
Original context
Read the surrounding source passage
first_layer_past_key_value = past_key_values[0][0][:, :, :, 0]
# Sum all dimensions of head_dim (-2) to avoid random errors such as: https://github.com/huggingface/transformers/pull/28032#issuecomment-1863691941
batch_index, non_attended_tokens = torch.where(
first_layer_past_key_value.float().sum(-2) == 0)
# Get the target length
target_length = input_ids.shape[1]Exact original notation
batch_index, non_attended_tokens = torch.where(
first_layer_past_key_value.float().sum(-2) == 0)Related builds
Sources & provenance
batch_index, non_attended_tokens = torch.where( first_layer_past_key_value.float().sum(-2) == 0)