class_docstr: Continuous Bernoulli distribution.
  
  This distribution is parameterized by `probs`, a (batch of) parameters
  taking values in `(0, 1)`. Note that, unlike in the Bernoulli case, `probs`
  does not correspond to a probability, but the same name is used due to the
  similarity with the Bernoulli.
  
  #### Mathematical Details
  
  The continuous Bernoulli is a distribution over the interval `[0, 1]`,
  parameterized by `probs` in `(0, 1)`.
  
  The probability density function (pdf) is,
  
  ```none
  pdf(x; probs) = probs**x * (1 - probs)**(1 - x) * C(probs)
  C(probs) = (2 * atanh(1 - 2 * probs) / (1 - 2 * probs) if probs != 0.5
              else 2.)
  ```
  
  While the normalizing constant `C(probs)` is a continuous function of `probs`
  (even at `probs = 0.5`), computing it at values close to 0.5 can result in
  numerical instabilities due to 0/0 errors. A Taylor approximation of
  `C(probs)` is thus used for values of `probs`
  in a small interval around 0.5.
  
  NOTE: Unlike the Bernoulli, numerical instabilities can happen for `probs`
  very close to 0 or 1. Current implementation allows any value in `(0, 1)`,
  but this could be changed to `(1e-6, 1-1e-6)` to avoid these issues.
  
  #### References
  
  [1] Loaiza-Ganem G and Cunningham JP. The continuous Bernoulli: fixing a
      pervasive error in variational autoencoders. NeurIPS2019.
      https://arxiv.org/abs/1907.06845
code: def _mean(self, logits=None):
      # The mean is probs / (2 * probs - 1) + 1 / (2 * arctanh(1 - 2 * probs))
      # with the removable singularity at 0.5 removed.
      # We write this in logits space.
      # The first term becomes
      # 1 / (1 + exp(-logits)) / (2 / (1 + exp(-logits)) - 1) =
      # 1 / (2 - 1 - exp(-logits)) =
      # 1 / (1 - exp(-logits))
      # The second term becomes - 1 / logits.
      # Thus we have mean = 1 / (1 - exp(-logits)) - 1 / logits.
  
      # When logits is close to zero, we can compute the Laurent series for the
      # first term as:
      # 1 / x + 1 / 2 + x / 12 - x**3 / 720 + x**5 / 30240 + O(x**7).
      # Thus we get the pole at zero canceling out with the second term.
  
      # For large negative logits, the denominator (1 - exp(-logits)) in
      # the first term yields inf values. Whilst the ratio still returns
      # zero as it should, the gradients of this ratio become nan.
      # Thus, noting that 1 / (1 - exp(-logits)) quickly tends towards 0
      # for large negative logits, the mean tends towards - 1 / logits.
  
      dtype = dtype_util.as_numpy_dtype(self.dtype)
      eps = np.finfo(dtype).eps
  
      if logits is None:
          logits = self._logits_parameter_no_checks()
  
      small_cutoff = np.power(eps * 30240, 1 / 5.0)
      result = (
          dtype(0.5)
          + logits / 12.0
          - logits * tf.math.square(logits) / 720
      )
  
      large_cutoff = -np.log(eps)
  
      safe_logits_mask = (tf.math.abs(logits) > small_cutoff) & (
          logits > -large_cutoff
      )
      safe_logits = tf.where(safe_logits_mask, logits, dtype(1.0))
      result = tf.where(
          safe_logits_mask,
          -(
              tf.math.reciprocal(tf.math.expm1(-safe_logits))
              + tf.math.reciprocal(safe_logits)
          ),
          result,
      )
  
      large_neg_mask = logits <= -large_cutoff
      logits_large_neg = tf.where(large_neg_mask, logits, 1.0)
      return tf.where(
          large_neg_mask, -tf.math.reciprocal(logits_large_neg), result
      )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import sigmoid
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math import generic
label_desc: Use image node_id 13 for calling the ContinuousBernoulli obj's underlying member method code with example usage: obj._mean(logits) and returns: tf