Skip to content

Commit

Permalink
Fix T_co import bug (#484)
Browse files Browse the repository at this point in the history
* Fix T_co import bug

* Fix styling
  • Loading branch information
gucci-j authored Jan 7, 2025
1 parent fdb12f4 commit 6560c75
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lighteval/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@
from typing import Iterator, Tuple

import torch
from packaging import version
from torch.utils.data import Dataset
from torch.utils.data.distributed import DistributedSampler, T_co


if version.parse(torch.__version__) >= version.parse("2.5.0"):
from torch.utils.data.distributed import DistributedSampler, _T_co
else:
from torch.utils.data.distributed import DistributedSampler
from torch.utils.data.distributed import T_co as _T_co

from lighteval.tasks.requests import (
GreedyUntilRequest,
Expand Down Expand Up @@ -318,7 +325,7 @@ class GenDistributedSampler(DistributedSampler):
as our samples are sorted by length.
"""

def __iter__(self) -> Iterator[T_co]:
def __iter__(self) -> Iterator[_T_co]:
if self.shuffle:
# deterministically shuffle based on epoch and seed
g = torch.Generator()
Expand Down

0 comments on commit 6560c75

Please sign in to comment.