code: def _tril_indices(n):
      """Emulate np.tril_indices(n, k=-1).
  
      This method ensures static shapes throughout (ie, XLA compilable).
      This method only works for n <= 30000.
  
      Args:
        n: number elements to generate all pairs
  
      Returns:
        A [2, n * (n - 1) / 2] vector of all combinations of range(n).
      """
      n = tf.convert_to_tensor(n, dtype_hint=tf.int32)
      # Number of lower triangular entries in an nxn matrix
      m = (n - 1) * n / 2
      r = tf.cast(tf.range(m), dtype=tf.float64)
  
      # From Sloane: https://oeis.org/A002024 "k appears k times"
      # e.g., [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, ...]
      e = tf.math.floor(tf.math.sqrt(2 * (r + 1)) + 0.5)
  
      # From Sloane: https://oeis.org/A002262 "Triangle read by rows"
      # e.g., [0, 0, 1, 0, 1, 2, 0, 1, 2, 3, ...]
      f = tf.math.floor(tf.math.sqrt(2 * r + 0.25) - 0.5)
      g = r - f * (f + 1) / 2
  
      return tf.cast(tf.stack([e, g]), dtype=tf.int32)
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 1 for calling a global function with example usage: _tril_indices(n) and returns: tf