MCPcopy Create free account
hub / github.com/huggingface/transformers / __init__

Method __init__

src/transformers/trainer.py:95–108  ·  view source on GitHub ↗
(self, dataset, num_replicas=None, rank=None)

Source from the content-addressed store, hash-verified

93 """
94
95 def __init__(self, dataset, num_replicas=None, rank=None):
96 if num_replicas is None:
97 if not torch.distributed.is_available():
98 raise RuntimeError("Requires distributed package to be available")
99 num_replicas = torch.distributed.get_world_size()
100 if rank is None:
101 if not torch.distributed.is_available():
102 raise RuntimeError("Requires distributed package to be available")
103 rank = torch.distributed.get_rank()
104 self.dataset = dataset
105 self.num_replicas = num_replicas
106 self.rank = rank
107 self.num_samples = int(math.ceil(len(self.dataset) * 1.0 / self.num_replicas))
108 self.total_size = self.num_samples * self.num_replicas
109
110 def __iter__(self):
111 indices = list(range(len(self.dataset)))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected