code: def self_all_attention(facts, ATTENTION_SIZE, mask, stag="null"):
      if len(facts.get_shape().as_list()) == 2:
          facts = tf.expand_dims(facts, 1)
  
      def cond(batch, output, i):
          return tf.less(i, tf.shape(batch)[1])
  
      def body(batch, output, i):
          self_attention_tmp = din_fcn_attention(
              batch[:, i, :],
              batch,
              ATTENTION_SIZE,
              mask,
              softmax_stag=1,
              stag=stag,
              mode="LIST",
          )
          self_attention_tmp = tf.reduce_sum(self_attention_tmp, 1)
          output = output.write(i, self_attention_tmp)
          return batch, output, i + 1
  
      output_ta = tf.TensorArray(
          dtype=tf.float32,
          size=0,
          dynamic_size=True,
          element_shape=(facts[:, 0, :].get_shape()),
      )
      _, output_op, _ = tf.while_loop(cond, body, [facts, output_ta, 0])
      self_attention = output_op.stack()
      self_attention = tf.transpose(self_attention, perm=[1, 0, 2])
      return self_attention
  
imports: import tensorflow
  from tensorflow.python.ops.rnn_cell import *
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.util import nest
  from tensorflow.python.ops import nn_ops
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 7 for calling a global function with example usage: self_all_attention(facts, ATTENTION_SIZE, mask, stag) and returns: self_attention, tf, batch,  output,  unknown