https://www.cnblogs.com/yi-xia/p/12468957.html
https://pytorch.org/docs/stable/nn.functional.html#gumbel-softmax
https://www.zhihu.com/question/62631725/answer/201338234
torch.nn.functional.gumbel_softmax(logits, tau=1, hard=False, eps=1e-10, dim=-1)
example:
>>> logits = torch.randn(20, 32)
>>> # Sample soft categorical using reparametrization trick:
>>> F.gumbel_softmax(logits, tau=1, hard=False)
>>> # Sample hard categorical using "Straight-through" trick:
>>> F.gumbel_softmax(logits, tau=1, hard=True)