code: def testStatelessParameterizedTruncatedNormalHasGrads(self):
      mean = variables.Variable(0.01)
      stddev = variables.Variable(1.0)
      minval = variables.Variable(-1.0)
      maxval = variables.Variable(1.0)
  
      with self.cached_session() as sess:
          with backprop.GradientTape(persistent=True) as tape:
              samples = (
                  stateless.stateless_parameterized_truncated_normal(
                      [1], [1, 2], mean, stddev, minval, maxval
                  )
              )
  
          sess.run(
              variables.variables_initializer(
                  [mean, stddev, minval, maxval]
              )
          )
          (
              [mean_grad, std_grad],
              mean_actual_grad,
              std_actual_grad,
          ) = sess.run(
              [
                  tape.gradient(samples, [mean, stddev]),
                  array_ops.ones_like(mean),
                  (samples - mean) / stddev,
              ]
          )
          self.assertAllClose(mean_grad, mean_actual_grad)
          self.assertAllClose(std_grad, std_actual_grad[0])
  
          try:
              import scipy.stats  # pylint:disable=g-import-not-at-top
  
              truncnorm = scipy.stats.truncnorm(
                  a=-1.0, b=1.0, loc=0.0, scale=1.0
              )
              samples_np, [minval_grad, maxval_grad] = sess.run(
                  [samples, tape.gradient(samples, [minval, maxval])]
              )
  
              sample_cdf = truncnorm.cdf(samples_np)
              # These come from the implicit reparameterization trick.
              scipy_maxval_grad = np.exp(
                  0.5 * (samples_np**2 - ((1.0 - 0.01) / 1.0) ** 2)
                  + np.log(sample_cdf)
              )
  
              scipy_minval_grad = np.exp(
                  0.5 * (samples_np**2 - ((-1.0 - 0.01) / 1.0) ** 2)
                  + np.log1p(-sample_cdf)
              )
  
              self.assertAllClose(
                  minval_grad, scipy_minval_grad[0], rtol=1e-2
              )
              self.assertAllClose(
                  maxval_grad, scipy_maxval_grad[0], rtol=1e-2
              )
  
          except ImportError as e:
              tf_logging.warn(
                  "Cannot test truncated normal op: %s" % str(e)
              )
  
imports: import functools
  import math
  import timeit
  import numpy
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import backprop
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import stateless_random_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 15 for calling the ParameterizedTruncatedNormalTest obj's underlying member method code with example usage: obj.testStatelessParameterizedTruncatedNormalHasGrads() without return types