class_docstr: Distribution followed by tanh.
class_docstr_tok: ["Distribution","followed","by","tanh","."]
docstr: Initialize the distribution.
  
  Args:
    distribution: The distribution to transform.
    threshold: Clipping value of the action when computing the logprob.
    validate_args: Passed to super class.
docstr_tok: ["Initialize","the","distribution",".","Args",":","distribution",":","The","distribution","to","transform",".","threshold",":","Clipping","value","of","the","action","when","computing","the","logprob",".","validate_args",":","Passed","to","super","class","."]
code: def __init__(
      self, distribution, threshold=0.999, validate_args=False
  ):
      """Initialize the distribution.
  
      Args:
        distribution: The distribution to transform.
        threshold: Clipping value of the action when computing the logprob.
        validate_args: Passed to super class.
      """
      super().__init__(
          distribution=distribution,
          bijector=tfp.bijectors.Tanh(),
          validate_args=validate_args,
      )
      # Computes the log of the average probability distribution outside the
      # clipping range, i.e. on the interval [-inf, -atanh(threshold)] for
      # log_prob_left and [atanh(threshold), inf] for log_prob_right.
      self._threshold = threshold
      inverse_threshold = self.bijector.inverse(threshold)
      # average(pdf) = p/epsilon
      # So log(average(pdf)) = log(p) - log(epsilon)
      log_epsilon = jnp.log(1.0 - threshold)
      # Those 2 values are differentiable w.r.t. model parameters, such that the
      # gradient is defined everywhere.
      self._log_prob_left = (
          self.distribution.log_cdf(-inverse_threshold) - log_epsilon
      )
      self._log_prob_right = (
          self.distribution.log_survival_function(inverse_threshold)
          - log_epsilon
      )
  
imports: from typing import Any, List, Optional, Sequence, Union, Callable
  import chex
  import haiku
  import jax
  import jax.numpy
  import numpy
  import tensorflow_probability
  import tensorflow_probability.substrates.jax
label_desc: Use image node_id 1 to create a new TanhTransformedDistribution object from inherited base classes: tfd with example: obj = TanhTransformedDistribution(distribution, threshold, validate_args)