(x, loss_reduction='square')
| 314 | |
| 315 | |
| 316 | def len2weight(x, loss_reduction='square'): |
| 317 | if x == 0: |
| 318 | return x |
| 319 | if loss_reduction == 'token': |
| 320 | return 1 |
| 321 | if loss_reduction == 'sample': |
| 322 | return 1 / x |
| 323 | if loss_reduction == 'square': |
| 324 | return 1 / (x ** 0.5) |
| 325 | raise NotImplementedError(loss_reduction) |
| 326 | |
| 327 | |
| 328 | def apply_template_qwenvl2_reconThenUnd(question_with_image_tokens,answer): |
no outgoing calls
no test coverage detected