class_docstr: The Truncated Normal distribution.
  
  The truncated normal is a normal distribution bounded between `low`
  and `high` (the pdf is 0 outside these bounds and renormalized).
  
  Samples from this distribution are differentiable with respect to `loc`,
  `scale` as well as the bounds, `low` and `high`, i.e., this
  implementation is fully reparameterized.
  
  For more details, see [here](
  https://en.wikipedia.org/wiki/Truncated_normal_distribution).
  
  ### Mathematical Details
  
  The probability density function (pdf) of this distribution is:
  ```none
    pdf(x; loc, scale, low, high) =
        { (2 pi)**(-0.5) exp(-0.5 y**2) / (scale * z) for low <= x <= high
        { 0                                    otherwise
    y = (x - loc)/scale
    z = NormalCDF((high - loc) / scale) - NormalCDF((low - loc) / scale)
  ```
  
  where:
  
  * `NormalCDF` is the cumulative density function of the Normal distribution
    with 0 mean and unit variance.
  
  This is a scalar distribution so the event shape is always scalar and the
  dimensions of the parameters define the batch_shape.
  
  #### Examples
  ```python
  
  tfd = tfp.distributions
  # Define a batch of two scalar TruncatedNormals with modes at 0. and 1.0
  dist = tfd.TruncatedNormal(loc=[0., 1.], scale=1.,
                             low=[-1., 0.],
                             high=[1., 1.])
  
  # Evaluate the pdf of the distributions at 0.5 and 0.8 respectively returning
  # a 2-vector tensor.
  dist.prob([0.5, 0.8])
  
  # Get 3 samples, returning a 3 x 2 tensor.
  dist.sample([3])
  ```
docstr: Construct TruncatedNormal.
  
  All parameters of the distribution will be broadcast to the same shape,
  so the resulting distribution will have a batch_shape of the broadcast
  shape of all parameters.
  
  Args:
    loc: Floating point tensor; the mean of the normal distribution(s) (
      note that the mean of the resulting distribution will be different
      since it is modified by the bounds).
    scale: Floating point tensor; the std deviation of the normal
      distribution(s).
    low: `float` `Tensor` representing lower bound of the distribution's
      support. Must be such that `low < high`.
    high: `float` `Tensor` representing upper bound of the distribution's
      support. Must be such that `low < high`.
    validate_args: Python `bool`, default `False`. When `True` distribution
      parameters are checked at run-time.
    allow_nan_stats: Python `bool`, default `True`. When `True`,
      statistics (e.g., mean, mode, variance) use the value '`NaN`' to
      indicate the result is undefined. When `False`, an exception is raised
      if one or more of the statistic's batch members are undefined.
    name: Python `str` name prefixed to Ops created by this class.
docstr_tok: ["Construct","TruncatedNormal",".","All","parameters","of","the","distribution","will","be","broadcast","to","the","same","shape",",","so","the","resulting","distribution","will","have","a","batch_shape","of","the","broadcast","shape","of","all","parameters",".","Args",":","loc",":","Floating","point","tensor",";","the","mean","of","the","normal","distribution","(","s",")","(","note","that","the","mean","of","the","resulting","distribution","will","be","different","since","it","is","modified","by","the","bounds",")",".","scale",":","Floating","point","tensor",";","the","std","deviation","of","the","normal","distribution","(","s",")",".","low",":","`","float","`","`","Tensor","`","representing","lower","bound","of","the","distribution's","support",".","Must","be","such","that","`","low","<","high","`",".","high",":","`","float","`","`","Tensor","`","representing","upper","bound","of","the","distribution's","support",".","Must","be","such","that","`","low","<","high","`",".","validate_args",":","Python","`","bool","`",",","default","`","False","`",".","When","`","True","`","distribution","parameters","are","checked","at","run-time",".","allow_nan_stats",":","Python","`","bool","`",",","default","`","True","`",".","When","`","True","`",",","statistics","(","e.g.",",","mean",",","mode",",","variance",")","use","the","value","'","`","NaN","`","'","to","indicate","the","result","is","undefined",".","When","`","False","`",",","an","exception","is","raised","if","one","or","more","of","the","statistic","'s","batch","members","are","undefined",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","class","."]
code: def __init__(
      self,
      loc,
      scale,
      low,
      high,
      validate_args=False,
      allow_nan_stats=True,
      name="TruncatedNormal",
  ):
      """Construct TruncatedNormal.
  
      All parameters of the distribution will be broadcast to the same shape,
      so the resulting distribution will have a batch_shape of the broadcast
      shape of all parameters.
  
      Args:
        loc: Floating point tensor; the mean of the normal distribution(s) (
          note that the mean of the resulting distribution will be different
          since it is modified by the bounds).
        scale: Floating point tensor; the std deviation of the normal
          distribution(s).
        low: `float` `Tensor` representing lower bound of the distribution's
          support. Must be such that `low < high`.
        high: `float` `Tensor` representing upper bound of the distribution's
          support. Must be such that `low < high`.
        validate_args: Python `bool`, default `False`. When `True` distribution
          parameters are checked at run-time.
        allow_nan_stats: Python `bool`, default `True`. When `True`,
          statistics (e.g., mean, mode, variance) use the value '`NaN`' to
          indicate the result is undefined. When `False`, an exception is raised
          if one or more of the statistic's batch members are undefined.
        name: Python `str` name prefixed to Ops created by this class.
      """
      parameters = dict(locals())
      with tf.name_scope(name) as name:
          dtype = dtype_util.common_dtype(
              [loc, scale, low, high], tf.float32
          )
          self._loc = tensor_util.convert_nonref_to_tensor(
              loc, name="loc", dtype=dtype
          )
          self._scale = tensor_util.convert_nonref_to_tensor(
              scale, name="scale", dtype=dtype
          )
          self._low = tensor_util.convert_nonref_to_tensor(
              low, name="low", dtype=dtype
          )
          self._high = tensor_util.convert_nonref_to_tensor(
              high, name="high", dtype=dtype
          )
          dtype_util.assert_same_float_dtype(
              [self._loc, self._scale, self._low, self._high]
          )
  
          super(TruncatedNormal, self).__init__(
              dtype=dtype,
              # This distribution is fully reparameterized. loc, scale have straight
              # through gradients. The gradients for the bounds are implemented
              # using custom derived expressions based on implicit gradients.
              # For the special case of lower bound zero and a positive upper bound
              # an equivalent expression can also be found in Sec 9.1.1.
              # of https://arxiv.org/pdf/1806.01851.pdf. The implementation here
              # handles arbitrary bounds.
              reparameterization_type=reparameterization.FULLY_REPARAMETERIZED,
              validate_args=validate_args,
              allow_nan_stats=allow_nan_stats,
              parameters=parameters,
              name=name,
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import sigmoid
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import distribution
  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 special_math
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math.generic import log_sub_exp
label_desc: Use image node_id 1 to create a new TruncatedNormal object from inherited base classes: distribution with example: obj = TruncatedNormal(loc, scale, low, high, validate_args, allow_nan_stats, name)