()
| 212 | |
| 213 | |
| 214 | def test_callback_hypothesis_id(): |
| 215 | hypotheses = collections.defaultdict(list) |
| 216 | |
| 217 | def _callback(step_result): |
| 218 | assert step_result.batch_id == 0 |
| 219 | hypotheses[step_result.hypothesis_id].append(step_result.token) |
| 220 | |
| 221 | source = ["آ", "ت", "ز", "م", "و", "ن"] |
| 222 | translator = _get_transliterator() |
| 223 | translator.translate_batch( |
| 224 | [source], |
| 225 | beam_size=1, |
| 226 | sampling_topk=20, |
| 227 | num_hypotheses=3, |
| 228 | callback=_callback, |
| 229 | ) |
| 230 | |
| 231 | assert len(hypotheses) == 3 |
| 232 | |
| 233 | |
| 234 | def test_callback_batch_id(): |
nothing calls this directly
no test coverage detected