(logits, tau=1, hard=False, eps=1e-10, dim=-1)
return functional.gumbel_softmax(logits, tau=tau, hard=hard, eps=eps, dim=dim)
Deals with the instability of the gumbel_softmax for older versions of torch.

        For more details about the issue:
        https://drive.google.com/file/d/1AA5wPfZ1kquaRtVruCd6BiYZGcDeNxyP/view?usp=sharing

        Args:
            logits […, num_features]:
                Unnormalized log probabilities
            tau:
                Non-negative scalar temperature
            hard (bool):
                If True, the returned samples will be discretized as one-hot vectors,
                but will be differentiated as if it is the soft sample in autograd
            dim (int):
                A dimension along which softmax will be computed. Default: -1.

        Returns:
            Sampled tensor of same shape as logits from the Gumbel-Softmax distribution.
Deals with the instability of the gumbel_softmax for older versions of torch.
Deals with the instability of the gumbel_softmax for older versions of torch .
def _gumbel_softmax(logits, tau=1, hard=False, eps=1e-10, dim=-1):
        """Deals with the instability of the gumbel_softmax for older versions of torch.

        For more details about the issue:
        https://drive.google.com/file/d/1AA5wPfZ1kquaRtVruCd6BiYZGcDeNxyP/view?usp=sharing

        Args:
            logits […, num_features]:
                Unnormalized log probabilities
            tau:
                Non-negative scalar temperature
            hard (bool):
                If True, the returned samples will be discretized as one-hot vectors,
                but will be differentiated as if it is the soft sample in autograd
            dim (int):
                A dimension along which softmax will be computed. Default: -1.

        Returns:
            Sampled tensor of same shape as logits from the Gumbel-Softmax distribution.
        """
        if version.parse(torch.__version__) < version.parse('1.2.0'):
            for i in range(10):
                transformed = functional.gumbel_softmax(logits, tau=tau, hard=hard,
                                                        eps=eps, dim=dim)
                if not torch.isnan(transformed).any():
                    return transformed
            raise ValueError('gumbel_softmax returning NaN.')

        return functional.gumbel_softmax(logits, tau=tau, hard=hard, eps=eps, dim=dim)
def _gumbel_softmax ( logits , tau = 1 , hard = False , eps = 1e-10 , dim = - 1 ) : if version . parse ( torch . __version__ ) < version . parse ( '1.2.0' ) : for i in range ( 10 ) : transformed = functional . gumbel_softmax ( logits , tau = tau , hard = hard , eps = eps , dim = dim ) if not torch . isnan ( transformed ) . any ( ) : return transformed raise ValueError ( 'gumbel_softmax returning NaN.' ) return functional . gumbel_softmax ( logits , tau = tau , hard = hard , eps = eps , dim = dim )