keras/src/legacy/layers.py/AlphaDropout/call
class AlphaDropout:    def call(self, inputs, training=False):
        if training and self.rate > 0:
            alpha = 1.6732632423543772848170429916717
            scale = 1.0507009873554804934193349852946
            alpha_p = -alpha * scale

            if self.noise_shape is None:
                noise_shape = tf.shape(inputs)
            else:
                noise_shape = self.noise_shape
            kept_idx = tf.greater_equal(
                backend.random.uniform(noise_shape),
                self.rate,
                seed=self.seed_generator,
            )
            kept_idx = tf.cast(kept_idx, inputs.dtype)

            # Get affine transformation params
            a = ((1 - self.rate) * (1 + self.rate * alpha_p**2)) ** -0.5
            b = -a * alpha_p * self.rate

            # Apply mask
            x = inputs * kept_idx + alpha_p * (1 - kept_idx)

            # Do affine transformation
            return a * x + b
        return inputs