← Walkthroughsrc/speech_decoding/models/v14_converged_v3/shaft_batch.py
Selected training excerpt · lines 148–160 · source SHA-256 b06c18319c16
148 drawn: list[tuple[ShaftRef, int]] = []149 total = 0150 # each iter adds ≥1 contact ⇒ the budget closes within contact_budget draws (draw is151 # WITH replacement, so the pool never "runs dry" — the loop always reaches the budget).152 for _ in range(contact_budget):153 r = self.draw(generator)154 room = contact_budget - total155 if r.n_contacts >= room: # this shaft closes (or overshoots) the budget → trim it156 drawn.append((r, room))157 return drawn158 drawn.append((r, r.n_contacts))159 total += r.n_contacts160 return drawn