Wraps an arbitrary object with __len__ and __getitem__ into a pytorch dataset
| 336 | |
| 337 | |
| 338 | class WrappedDataset(Dataset): |
| 339 | """Wraps an arbitrary object with __len__ and __getitem__ into a pytorch dataset""" |
| 340 | |
| 341 | def __init__(self, dataset): |
| 342 | self.data = dataset |
| 343 | |
| 344 | def __len__(self): |
| 345 | return len(self.data) |
| 346 | |
| 347 | def __getitem__(self, idx): |
| 348 | return self.data[idx] |
| 349 | |
| 350 | |
| 351 | def worker_init_fn(_): |