MCPcopy Create free account
hub / github.com/MiniMax-AI/VTP / InfiniteSampler

Class InfiniteSampler

tools/test_linear_probing_hf.py:192–209  ·  view source on GitHub ↗

Wraps another sampler to yield an infinite stream of indices.

Source from the content-addressed store, hash-verified

190# ============================================================================
191
192class InfiniteSampler(Sampler):
193 """Wraps another sampler to yield an infinite stream of indices."""
194
195 def __init__(self, sampler: Sampler, shuffle: bool = True, seed: int = 0):
196 self.sampler = sampler
197 self.shuffle = shuffle
198 self.seed = seed
199 self.epoch = 0
200
201 def __iter__(self):
202 while True:
203 if hasattr(self.sampler, 'set_epoch'):
204 self.sampler.set_epoch(self.epoch)
205 yield from iter(self.sampler)
206 self.epoch += 1
207
208 def __len__(self):
209 return int(1e18) # Effectively infinite
210
211
212# ============================================================================

Callers 1

test_linear_probingFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_linear_probingFunction · 0.68