code: def no_pivot_ldl(matrix, name="no_pivot_ldl"):
      """Non-pivoted batched LDL factorization.
  
      Performs the LDL factorization, using the outer product algorithm from [1]. No
      pivoting (or block pivoting) is done, so this should be less stable than
      e.g. Bunch-Kaufman sytrf. This is implemented as a tf.foldl, so should have
      gradients and be accelerator-friendly, but is not particularly performant.
  
      If compiling with XLA, make sure any surrounding GradientTape is also
      XLA-compiled (b/193584244).
  
      #### References
      [1]: Gene H. Golub, Charles F. Van Loan. Matrix Computations, 4th ed., 2013.
  
      Args:
        matrix: A batch of symmetric square matrices, with shape `[..., n, n]`.
        name: Python `str` name prefixed to Ops created by this function.
          Default value: 'no_pivot_ldl'.
  
      Returns:
        triangular_factor: The unit lower triangular L factor of the LDL
          factorization of `matrix`, with the same shape `[..., n, n]`. Callers
          should check for `nans` and other indicators of instability.
        diag: The diagonal from the LDL factorization, with shape `[..., n]`.
      """
      with tf.name_scope(name) as name:
          matrix = tf.convert_to_tensor(matrix)
          triangular_factor = tf.linalg.band_part(
              matrix, num_lower=-1, num_upper=0
          )
          # TODO(b/182276317) Deal with dynamic ranks better.
          slix = _Slice2Idx(triangular_factor)
  
          def fn(triangular_factor, i):
              column_head = triangular_factor[..., i, i, tf.newaxis]
              column_tail = triangular_factor[..., i + 1 :, i]
              rescaled_tail = column_tail / column_head
              triangular_factor = tf.tensor_scatter_nd_update(
                  triangular_factor,
                  slix[..., i + 1 :, i],
                  rescaled_tail,
              )
              triangular_factor = tf.tensor_scatter_nd_sub(
                  triangular_factor,
                  slix[..., i + 1 :, i + 1 :],
                  tf.linalg.band_part(
                      tf.einsum(
                          "...i,...j->...ij", column_tail, rescaled_tail
                      ),
                      num_lower=-1,
                      num_upper=0,
                  ),
              )
              return triangular_factor
  
          triangular_factor = tf.foldl(
              fn=fn,
              elems=tf.range(tf.shape(triangular_factor)[-1]),
              initializer=triangular_factor,
          )
  
          diag = tf.linalg.diag_part(triangular_factor)
          triangular_factor = tf.linalg.set_diag(
              triangular_factor, tf.ones_like(diag)
          )
  
          return triangular_factor, diag
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 1 for calling a global function with example usage: no_pivot_ldl(matrix, name) and returns: triangular_factor,  diag, triangular_factor