class_docstr: Matrix-vector multiply using LU decomposition.
  
  This bijector is identical to the 'Convolution1x1' used in Glow
  [(Kingma and Dhariwal, 2018)[1].
  
  #### Examples
  
  Here's an example of initialization via random weights matrix:
  
  ```python
  def trainable_lu_factorization(
      event_size, batch_shape=(), seed=None, dtype=tf.float32, name=None):
    with tf.name_scope(name or 'trainable_lu_factorization'):
      event_size = tf.convert_to_tensor(
          event_size, dtype_hint=tf.int32, name='event_size')
      batch_shape = tf.convert_to_tensor(
          batch_shape, dtype_hint=event_size.dtype, name='batch_shape')
      random_matrix = tf.random.uniform(
          shape=tf.concat([batch_shape, [event_size, event_size]], axis=0),
          dtype=dtype,
          seed=seed)
      random_orthonormal = tf.linalg.qr(random_matrix)[0]
      lower_upper, permutation = tf.linalg.lu(random_orthonormal)
      lower_upper = tf.Variable(
          initial_value=lower_upper,
          trainable=True,
          name='lower_upper')
      # Initialize a non-trainable variable for the permutation indices so
      # that its value isn't re-sampled from run-to-run.
      permutation = tf.Variable(
          initial_value=permutation,
          trainable=False,
          name='permutation')
      return lower_upper, permutation
  
  channels = 3
  conv1x1 = tfb.ScaleMatvecLU(*trainable_lu_factorization(channels),
                              validate_args=True)
  x = tf.random.uniform(shape=[2, 28, 28, channels])
  fwd = conv1x1.forward(x)
  rev_fwd = conv1x1.inverse(fwd)
  # ==> x
  ```
  
  To initialize this variable outside of TensorFlow, one can also use SciPy,
  e.g.,
  
  ```python
  def lu_factorized_random_orthonormal_matrix(channels, dtype=np.float32):
    random_matrix = np.random.rand(channels, channels).astype(dtype)
    lower_upper = scipy.linalg.qr(random_matrix)[0]
    permutation = scipy.linalg.lu(lower_upper, overwrite_a=True)[0]
    permutation = np.argmax(permutation, axis=-2)
    return lower_upper, permutation
  ```
  
  #### References
  
  [1]: Diederik P. Kingma, Prafulla Dhariwal. Glow: Generative Flow with
       Invertible 1x1 Convolutions. _arXiv preprint arXiv:1807.03039_, 2018.
       https://arxiv.org/abs/1807.03039
class_docstr_tok: ["Matrix-vector","multiply","using","LU","decomposition",".","This","bijector","is","identical","to","the","'Convolution1x1","'","used","in","Glow","[","(","Kingma","and","Dhariwal",",","2018",")","[","1","]",".","#","#","#","#","Examples","Here","'s","an","example","of","initialization","via","random","weights","matrix",":","``","`","python","def","trainable_lu_factorization","(","event_size",",","batch_shape=","(",")",",","seed=None",",","dtype=tf.float32",",","name=None",")",":","with","tf.name_scope","(","name","or","'trainable_lu_factorization","'",")",":","event_size","=","tf.convert_to_tensor","(","event_size",",","dtype_hint=tf.int32",",","name='event_size","'",")","batch_shape","=","tf.convert_to_tensor","(","batch_shape",",","dtype_hint=event_size.dtype",",","name='batch_shape","'",")","random_matrix","=","tf.random.uniform","(","shape=tf.concat","(","[","batch_shape",",","[","event_size",",","event_size","]","]",",","axis=0",")",",","dtype=dtype",",","seed=seed",")","random_orthonormal","=","tf.linalg.qr","(","random_matrix",")","[","0","]","lower_upper",",","permutation","=","tf.linalg.lu","(","random_orthonormal",")","lower_upper","=","tf.Variable","(","initial_value=lower_upper",",","trainable=True",",","name='lower_upper","'",")","#","Initialize","a","non-trainable","variable","for","the","permutation","indices","so","#","that","its","value","is","n't","re-sampled","from","run-to-run",".","permutation","=","tf.Variable","(","initial_value=permutation",",","trainable=False",",","name='permutation","'",")","return","lower_upper",",","permutation","channels","=","3","conv1x1","=","tfb.ScaleMatvecLU","(","*","trainable_lu_factorization","(","channels",")",",","validate_args=True",")","x","=","tf.random.uniform","(","shape=","[","2",",","28",",","28",",","channels","]",")","fwd","=","conv1x1.forward","(","x",")","rev_fwd","=","conv1x1.inverse","(","fwd",")","#","==",">","x","``","`","To","initialize","this","variable","outside","of","TensorFlow",",","one","can","also","use","SciPy",",","e.g.",",","``","`","python","def","lu_factorized_random_orthonormal_matrix","(","channels",",","dtype=np.float32",")",":","random_matrix","=","np.random.rand","(","channels",",","channels",")",".astype","(","dtype",")","lower_upper","=","scipy.linalg.qr","(","random_matrix",")","[","0","]","permutation","=","scipy.linalg.lu","(","lower_upper",",","overwrite_a=True",")","[","0","]","permutation","=","np.argmax","(","permutation",",","axis=-2",")","return","lower_upper",",","permutation","``","`","#","#","#","#","References","[","1","]",":","Diederik","P.","Kingma",",","Prafulla","Dhariwal",".","Glow",":","Generative","Flow","with","Invertible","1x1","Convolutions",".","_arXiv","preprint","arXiv:1807.03039_",",","2018.","https",":","\/\/arxiv.org\/abs\/1807.03039"]
code: def _parameter_control_dependencies(self, is_init):
      if not self.validate_args:
          return []
  
      lu, perm = None, None
      assertions = []
      if is_init != tensor_util.is_ref(
          self.lower_upper
      ) or is_init != tensor_util.is_ref(self.permutation):
          lu, perm = self._broadcast_params()
          assertions.extend(
              lu_reconstruct_assertions(lu, perm, self.validate_args)
          )
  
      if is_init != tensor_util.is_ref(self.lower_upper):
          lu = (
              tf.convert_to_tensor(self.lower_upper)
              if lu is None
              else lu
          )
          assertions.append(
              assert_util.assert_none_equal(
                  tf.linalg.diag_part(lu),
                  tf.zeros([], dtype=lu.dtype),
                  message="Invertible `lower_upper` must have nonzero diagonal.",
              )
          )
  
      return assertions
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math.linalg import lu_reconstruct
  from tensorflow_probability.python.math.linalg import lu_reconstruct_assertions
  from tensorflow_probability.python.math.linalg import lu_solve
  from tensorflow.python.util import deprecation
label_desc: Use image node_id 9 for calling the ScaleMatvecLU obj's underlying member method code with example usage: obj._parameter_control_dependencies(is_init) and returns: assertions, list