(d)
| 44 | return d |
| 45 | |
| 46 | def normalize(d): |
| 47 | # d is B x whatever. normalize within each element of the batch |
| 48 | out = torch.zeros(d.size()) |
| 49 | if d.is_cuda: |
| 50 | out = out.cuda() |
| 51 | B = list(d.size())[0] |
| 52 | for b in list(range(B)): |
| 53 | out[b] = normalize_single(d[b]) |
| 54 | return out |
| 55 | |
| 56 | def reduce_masked_mean(x, mask, dim=None, keepdim=False): |
| 57 | # x and mask are the same shape, or at least broadcastably so |
nothing calls this directly
no test coverage detected