code: def test_invertible_from_lu(self):
      lower_upper, permutation = tf.linalg.lu(
          [[1.0, 2, 3], [4, 5, 6], [0.5, 0.0, 0.25]]
      )
  
      conv1x1 = scale_matvec_lu.ScaleMatvecLU(
          lower_upper=lower_upper,
          permutation=permutation,
          validate_args=True,
      )
  
      channels = tf.compat.dimension_value(lower_upper.shape[-1])
      x_ = np.random.uniform(size=[2, 28, 28, channels]).astype(
          np.float32
      )
  
      fwd = conv1x1.forward(x_)
      rev_fwd = conv1x1.inverse(fwd)
      fldj = conv1x1.forward_log_det_jacobian(x_, event_ndims=3)
  
      rev = conv1x1.inverse(x_)
      fwd_rev = conv1x1.forward(rev)
      ildj = conv1x1.inverse_log_det_jacobian(x_, event_ndims=3)
  
      [fwd_, rev_, fwd_rev_, rev_fwd_, fldj_, ildj_] = self.evaluate(
          [fwd, rev, fwd_rev, rev_fwd, fldj, ildj]
      )
  
      self.assertAllClose(x_, fwd_rev_, atol=1e-3, rtol=1e-6)
      self.assertAllClose(x_, rev_fwd_, atol=1e-3, rtol=1e-6)
  
      self.assertEqual(fldj_, -ildj_)
      self.assertTrue(fldj_ > 1.0)  # Notably, bounded away from zero.
  
      # We now check that the bijector isn't simply the identity function. We do
      # this by checking that at least 50% of pixels differ by at least 10%.
      self.assertTrue(np.mean(np.abs(x_ - fwd_) > 0.1 * x_) > 0.5)
      self.assertTrue(np.mean(np.abs(x_ - rev_) > 0.1 * x_) > 0.5)
  
file_path: probability/tensorflow_probability/python/bijectors/scale_matvec_lu_test.py
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector_test_util
  from tensorflow_probability.python.bijectors import scale_matvec_lu
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 3 for calling the ScaleMatvecLUTest obj's underlying member method code with example usage: obj.test_invertible_from_lu() without return types