def bernoulli_concrete_sample(logits, temperature, shape=torch.Size([])):
    '\n    Sampling for BinConcrete distribution.\n\n    See PyTorch source code, differs from Eq. 16 of Maddison et al., 2017.\n    '
    uniform_shape = (torch.Size(shape) + logits.shape)
    u = clamp_probs(torch.rand(uniform_shape, dtype=torch.float32, device=logits.device))
    return torch.sigmoid(((((F.logsigmoid(logits) - F.logsigmoid((- logits))) + torch.log(u)) - torch.log((1 - u))) / temperature))
Sampling for BinConcrete distribution.

See PyTorch source code, differs from Eq. 16 of Maddison et al., 2017.
def bernoulli_concrete_sample(logits, temperature, shape=torch.Size([])):
    '\n    Sampling for BinConcrete distribution.\n\n    See PyTorch source code, differs from Eq. 16 of Maddison et al., 2017.\n    '
    uniform_shape = (torch.Size(shape) + logits.shape)
    u = clamp_probs(torch.rand(uniform_shape, dtype=torch.float32, device=logits.device))
    return torch.sigmoid(((((F.logsigmoid(logits) - F.logsigmoid((- logits))) + torch.log(u)) - torch.log((1 - u))) / temperature))