code: def calc_auc(raw_arr):
      """Summary
  
      Args:
          raw_arr (TYPE): Description
  
      Returns:
          TYPE: Description
      """
  
      arr = sorted(raw_arr, key=lambda d: d[0], reverse=True)
      pos, neg = 0.0, 0.0
      for record in arr:
          if record[1] == 1.0:
              pos += 1
          else:
              neg += 1
  
      fp, tp = 0.0, 0.0
      xy_arr = []
      for record in arr:
          if record[1] == 1.0:
              tp += 1
          else:
              fp += 1
          xy_arr.append([fp / neg, tp / pos])
  
      auc = 0.0
      prev_x = 0.0
      prev_y = 0.0
      for x, y in xy_arr:
          if x != prev_x:
              auc += (x - prev_x) * (y + prev_y) / 2.0
              prev_x = x
              prev_y = y
  
      return auc
  
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 2 for calling a global function with example usage: calc_auc(raw_arr) and returns: auc