File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 25
25
from typing import Iterator , Tuple
26
26
27
27
import torch
28
+ from packaging import version
28
29
from torch .utils .data import Dataset
29
- from torch .utils .data .distributed import DistributedSampler , T_co
30
+
31
+
32
+ if version .parse (torch .__version__ ) >= version .parse ("2.5.0" ):
33
+ from torch .utils .data .distributed import DistributedSampler , _T_co
34
+ else :
35
+ from torch .utils .data .distributed import DistributedSampler
36
+ from torch .utils .data .distributed import T_co as _T_co
30
37
31
38
from lighteval .tasks .requests import (
32
39
GreedyUntilRequest ,
@@ -318,7 +325,7 @@ class GenDistributedSampler(DistributedSampler):
318
325
as our samples are sorted by length.
319
326
"""
320
327
321
- def __iter__ (self ) -> Iterator [T_co ]:
328
+ def __iter__ (self ) -> Iterator [_T_co ]:
322
329
if self .shuffle :
323
330
# deterministically shuffle based on epoch and seed
324
331
g = torch .Generator ()
You can’t perform that action at this time.
0 commit comments