code: def mask_attn_weights(w):
      n = shape_list(w)[-1]
      b = tf.linalg.band_part(tf.ones([n, n]), -1, 0)
      b = tf.reshape(b, [1, 1, n, n])
      w = w * b + -1e9 * (1 - b)
      return w
  
imports: import functools
  import numpy
  import tensorflow
  from finetune.optimizers.recompute_grads import recompute_grad
  from finetune.util.shapes import shape_list, lengths_from_eos_idx
  from finetune.nn.activations import act_fns
  from finetune.nn.nn_utils import dropout, norm
label_desc: Use image node_id 1 for calling a global function with example usage: mask_attn_weights(w) and returns: w