code: def tf_masked_triangular_solve(L, y, mask, lower=True, adjoint=False):
      """Tensorflow function to solve L x = y
      where L is a lower triangular matrix with a mask
  
      Arguments
      ---------
      L : 2-D tensor
          Must be a tensorflow tensor and
          must be a triangular matrix of dimension n x n
  
      y : 1-D or 2-D tensor
          Dimension n x p
  
      mask : 1-D tensor
          Dimension n x 1, should be 1 if element is valid, 0 if invalid
  
      lower : boolean (default : True)
          True if L is lower triangular, False if upper triangular
  
      adjoint : boolean (default : False)
          True if solving for L^T x = y, False if solving for Lx = y
  
      Returns
      -------
      x : 1-D or 2-D tensor
          Dimension n x p, values at rows for which mask == 0 are set to zero
  
      """
  
      zero = tf.constant(0, dtype=tf.int32)
      mask_mat = tf.compat.v1.where(
          tf.not_equal(
              tf.matmul(
                  tf.reshape(mask, [-1, 1]), tf.reshape(mask, [1, -1])
              ),
              zero,
          )
      )
      q = tf.cast(
          tf.sqrt(
              tf.cast(tf.shape(input=mask_mat)[0], dtype=tf.float64)
          ),
          dtype=tf.int32,
      )
      L_masked = tf.reshape(tf.gather_nd(L, mask_mat), [q, q])
  
      maskindex = tf.compat.v1.where(tf.not_equal(mask, zero))
      y_masked = tf.gather_nd(y, maskindex)
  
      x_s1 = tf.linalg.triangular_solve(
          L_masked, y_masked, lower=lower, adjoint=adjoint
      )
      x = tf.scatter_nd(
          maskindex, x_s1, tf.cast(tf.shape(input=y), dtype=tf.int64)
      )
      return x
  
imports: import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: tf_masked_triangular_solve(L, y, mask, lower, adjoint) and returns: x