code: def AUC(pos_mask, pred, excl_mask):
      def _map_fn(tups):
          user_pos_mask, user_pred, user_excl_mask = tups
  
          eval_mask = tf.math.logical_not(
              tf.math.logical_or(user_pos_mask, user_excl_mask)
          )
          eval_pred = user_pred[eval_mask]
          pos_pred = user_pred[user_pos_mask]
          eval_num = tf.math.count_nonzero(eval_mask, dtype=tf.int32)
          user_auc = tf.math.count_nonzero(
              eval_pred <= tf.reshape(pos_pred, (-1, 1)),
              dtype=tf.float32,
          ) / tf.cast(tf.size(pos_pred) * eval_num, dtype=tf.float32)
  
          return user_auc
  
      auc = tf.map_fn(
          _map_fn,
          (pos_mask, pred, excl_mask),
          parallel_iterations=10,
          dtype=tf.float32,
      )
  
      return auc
  
imports: import tensorflow
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: AUC(pos_mask, pred, excl_mask) and returns: auc, user_auc