(f, init, xs, length=None)
| 10 | |
| 11 | |
| 12 | def scan(f, init, xs, length=None): |
| 13 | if xs is None: |
| 14 | xs = [None] * length |
| 15 | carry = init |
| 16 | ys = [] |
| 17 | for x in xs: |
| 18 | carry, y = f(carry, x) |
| 19 | ys.append(y) |
| 20 | |
| 21 | return carry, torch.stack(ys) if ys[0] is not None else None |
| 22 | |
| 23 | |
| 24 | def word_frequency(path, basic_freq=.5): |
nothing calls this directly
no outgoing calls
no test coverage detected