wrapper
()
| 197 | examples = self._read_tsv(input_file) |
| 198 | |
| 199 | def wrapper(): |
| 200 | """wrapper""" |
| 201 | all_dev_batches = [] |
| 202 | trainer_id = 0 |
| 203 | for epoch_index in range(epoch): |
| 204 | if phase == "train": |
| 205 | self.current_example = 0 |
| 206 | self.current_epoch = epoch_index |
| 207 | self.random_seed = epoch_index |
| 208 | self.global_rng = np.random.RandomState(self.random_seed) |
| 209 | trainer_id = self.trainer_id |
| 210 | else: |
| 211 | trainer_id = 0 |
| 212 | assert dev_count == 1, "only supports 1 GPU while prediction" |
| 213 | current_examples = copy.deepcopy(examples) |
| 214 | if shuffle: |
| 215 | self.global_rng.shuffle(current_examples) |
| 216 | for batch_data in self._prepare_batch_data( |
| 217 | current_examples, batch_size, phase=phase): |
| 218 | if len(all_dev_batches) < dev_count: |
| 219 | all_dev_batches.append(batch_data) |
| 220 | if len(all_dev_batches) == dev_count: |
| 221 | yield all_dev_batches[trainer_id] |
| 222 | all_dev_batches = [] |
| 223 | if phase != "train" and self.trainer_id < len(all_dev_batches): |
| 224 | yield all_dev_batches[self.trainer_id] |
| 225 | return wrapper |
| 226 | |
| 227 |
nothing calls this directly
no test coverage detected