So target is a boolean tensor. I think, maybe…
output = torch.randn(64, 134)
target = torch.randn(64, 134) > 0.5  # multi hot

def accuracy(output, target, topk=(1,)):
    maxk = max(topk)
    batch_size = target.size(0)

    _, pred = output.topk(maxk, dim=1, largest=True, sorted=True)
    print(pred.shape)
    ret = []
    for k in topk:
        correct = (target * torch.zeros_like(target).scatter(1, pred[:, :k], 1)).float()
        ret.append(correct.sum() / target.sum())
    return ret
## using
acc = accuracy(output, target, topk=(1,2,5))
print(acc)