(li)
| 124 | final_hiddens: list[torch.Tensor] | None = [] if capture_final else None |
| 125 | |
| 126 | def make_hook(li): |
| 127 | def _hook(_m, args, kwargs): |
| 128 | x = kwargs.get("hidden_states") if kwargs else None |
| 129 | if x is None and args: |
| 130 | x = args[0] |
| 131 | captured[li].append(x.detach().to("cpu")) |
| 132 | return _hook |
| 133 | |
| 134 | def _final_hook(_m, args, kwargs): |
| 135 | x = kwargs.get("hidden_states") if kwargs else None |
no outgoing calls
no test coverage detected