code: def _two_piece_normal_sample_gradient(skewness, samples):
      """Compute the gradients of Two-Piece Normal samples w.r.t. skewness.
  
      This function computes the implicit reparameterization gradients [1]:
  
      ```none
      dz / dskewness = -(dF(z; 0, 1, skewness) / dskewness) / p(z; 0, 1, skewness)
      ```
  
      where `F(z; 0, 1, skewness)` and `p(z; 0, 1, skewness)` are the cdf and the
      pdf of the Two-Piece Normal distribution with location zero, scale one, and
      skewness `skewness`.
  
      Args:
        skewness: Floating-point tensor; the skewness(es) of the distribution(s).
        samples: Floating-point tensor; the samples of the distribution(s).
  
      Returns:
        A tensor with shape broadcast according to the arguments.
  
      Reference:
        [1]: Michael Figurnov, Shakir Mohamed, and Andriy Mnih.
             Implicit Reparameterization Gradients. In _Advances in Neural
             Information Processing Systems_, 31, 2018.
             https://arxiv.org/abs/1805.08498
      """
      one = tf.constant(1.0, dtype=skewness.dtype)
      two = tf.constant(2.0, dtype=skewness.dtype)
      sqrt_2 = tf.constant(np.sqrt(2.0), dtype=skewness.dtype)
      sqrt_pi_over_two = tf.constant(
          np.sqrt(np.pi / 2.0), dtype=skewness.dtype
      )
  
      left_piece = samples < 0.0
      z = samples * tf.where(
          left_piece, skewness, tf.math.reciprocal(skewness)
      )
  
      scale = tf.math.reciprocal(one + tf.math.square(skewness))
  
      safe_left_z = tf.where(left_piece, z, -tf.ones_like(z))
      safe_right_z = tf.where(left_piece, tf.ones_like(z), z)
  
      grad_left_piece = (
          -samples / skewness
          + scale
          * two
          * sqrt_pi_over_two
          * special.erfcx(-safe_left_z / sqrt_2)
      )
      grad_right_piece = (
          samples / skewness
          + scale
          * two
          * sqrt_pi_over_two
          * special.erfcx(safe_right_z / sqrt_2)
      )
  
      return tf.where(left_piece, grad_left_piece, grad_right_piece)
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  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 custom_gradient
  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 import special
  from tensorflow_probability.python.math.numeric import log1psquare
label_desc: Use image node_id 6 for calling a global function with example usage: _two_piece_normal_sample_gradient(skewness, samples) and returns: tf