(x, padding_idx=0)
| 210 | |
| 211 | |
| 212 | def remove_padding(x, padding_idx=0): |
| 213 | if x is None: |
| 214 | return None |
| 215 | assert len(x.shape) in [1, 2] |
| 216 | if len(x.shape) == 2: # [T, H] |
| 217 | return x[np.abs(x).sum(-1) != padding_idx] |
| 218 | elif len(x.shape) == 1: # [T] |
| 219 | return x[x != padding_idx] |
| 220 | |
| 221 | |
| 222 | class Timer: |
nothing calls this directly
no outgoing calls
no test coverage detected