Each token inherits the reshaped advantage of its turn. Implement broadcast_turn_to_tokens(turn_advantages, turn_ids):
turn_advantages: shape (K,) — for turns turn_ids: shape (T,) integer array; turn_ids[t] = k means token belongs to turn ( in the AgentOPSD paper)(T,) float array with out[t] = turn_advantages[turn_ids[t]]Tokens from the same turn must receive the identical advantage (GRPO-style broadcast, but at turn granularity rather than whole-trajectory).