(self, engine: SupervisedTrainer | SupervisedEvaluator, batchdata: dict[str, torch.Tensor])
| 55 | self.key_probability = key_probability |
| 56 | |
| 57 | def __call__(self, engine: SupervisedTrainer | SupervisedEvaluator, batchdata: dict[str, torch.Tensor]) -> dict: |
| 58 | if batchdata is None: |
| 59 | raise ValueError("Must provide batch data for current iteration.") |
| 60 | |
| 61 | for j in range(self.max_interactions): |
| 62 | inputs, _ = engine.prepare_batch(batchdata) |
| 63 | inputs = inputs.to(engine.state.device) |
| 64 | |
| 65 | engine.fire_event(IterationEvents.INNER_ITERATION_STARTED) |
| 66 | |
| 67 | engine.network.eval() |
| 68 | with torch.no_grad(): |
| 69 | if engine.amp: |
| 70 | with torch.autocast("cuda"): |
| 71 | predictions = engine.inferer(inputs, engine.network) |
| 72 | else: |
| 73 | predictions = engine.inferer(inputs, engine.network) |
| 74 | |
| 75 | engine.fire_event(IterationEvents.INNER_ITERATION_COMPLETED) |
| 76 | |
| 77 | batchdata.update({CommonKeys.PRED: predictions}) |
| 78 | |
| 79 | # decollate batch data to execute click transforms |
| 80 | batchdata_list = decollate_batch(batchdata, detach=True) |
| 81 | for i in range(len(batchdata_list)): |
| 82 | batchdata_list[i][self.key_probability] = ( |
| 83 | (1.0 - ((1.0 / self.max_interactions) * j)) if self.train else 1.0 |
| 84 | ) |
| 85 | batchdata_list[i] = self.transforms(batchdata_list[i]) |
| 86 | |
| 87 | # collate list into a batch for next round interaction |
| 88 | batchdata = list_data_collate(batchdata_list) |
| 89 | |
| 90 | return engine._iteration(engine, batchdata) # type: ignore[arg-type] |
nothing calls this directly
no test coverage detected