class_docstr: Tests correctness of the TransformDiagonal bijector.
class_docstr_tok: ["Tests","correctness","of","the","TransformDiagonal","bijector","."]
code: def testTheoreticalFldj(self, data):
      dim = data.draw(hps.integers(min_value=0, max_value=10))
      diag_bijector = data.draw(
          bijector_hps.unconstrained_bijectors(
              max_forward_event_ndims=1, must_preserve_event_ndims=True
          ).filter(_preserves_vector_dim(dim))
      )
      logging.info(
          "Using diagonal bijector %s %s",
          diag_bijector.name,
          diag_bijector,
      )
  
      bijector = transform_diagonal.TransformDiagonal(
          diag_bijector=diag_bijector
      )
      ensure_nonzero_batch = lambda shape: [
          d if d > 0 else 1 for d in shape
      ]
      shape = data.draw(tfp_hps.shapes().map(ensure_nonzero_batch)) + [
          dim,
          dim,
      ]
      x = np.random.randn(*shape).astype(np.float64)
      y = self.evaluate(bijector.forward(x))
      bijector_test_util.assert_bijective_and_finite(
          bijector,
          x,
          y,
          eval_func=self.evaluate,
          event_ndims=2,
          inverse_event_ndims=2,
          rtol=1e-5,
      )
      fldj = bijector.forward_log_det_jacobian(x, event_ndims=2)
      # For constant-jacobian bijectors, the zero fldj may not be broadcast.
      fldj = fldj + tf.zeros(tf.shape(x)[:-2], dtype=x.dtype)
      fldj_theoretical = bijector_test_util.get_fldj_theoretical(
          bijector, x, event_ndims=2, inverse_event_ndims=2
      )
      self.assertAllClose(
          self.evaluate(fldj_theoretical),
          self.evaluate(fldj),
          atol=1e-5,
          rtol=1e-5,
      )
  
file_path: probability/tensorflow_probability/python/bijectors/transform_diagonal_test.py
imports: from absl import logging
  import hypothesis
  import hypothesis.strategies
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.bijectors import exp
  from tensorflow_probability.python.bijectors import hypothesis_testlib
  from tensorflow_probability.python.bijectors import normal_cdf
  from tensorflow_probability.python.bijectors import transform_diagonal
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 3 for calling the TransformDiagonalBijectorTest obj's underlying member method code with example usage: obj.testTheoreticalFldj(data) without return types