code: def compute_roc_curve(
      labels, predictions, num_thresholds=None, weights=None
  ):
      """Compute ROC curve data by labels and predictions.
      Args:
          labels (numpy.ndarray or list): Binary labels for each element.
          predictions (numpy.ndarray or list): The probability that an element be
              classified as true.
          num_thresholds (int): Number of thresholds used to draw the curve.
          weights (float): Multiple of data to display on the curve.
      """
      if isinstance(labels, list):
          labels = np.array(labels)
      if isinstance(predictions, list):
          predictions = np.array(predictions)
      _MINIMUM_COUNT = 1e-7
  
      if weights is None:
          weights = 1.0
  
      bucket_indices = np.int32(
          np.floor(predictions * (num_thresholds - 1))
      )
      float_labels = labels.astype(np.float)
      histogram_range = (0, num_thresholds - 1)
      tp_buckets, _ = np.histogram(
          bucket_indices,
          bins=num_thresholds,
          range=histogram_range,
          weights=float_labels * weights,
      )
      fp_buckets, _ = np.histogram(
          bucket_indices,
          bins=num_thresholds,
          range=histogram_range,
          weights=(1.0 - float_labels) * weights,
      )
  
      # Obtain the reverse cumulative sum.
      tp = np.cumsum(tp_buckets[::-1])[::-1]
      fp = np.cumsum(fp_buckets[::-1])[::-1]
      tn = fp[0] - fp
      fn = tp[0] - tp
      tpr = tp / np.maximum(_MINIMUM_COUNT, tn + fp)
      fpr = fp / np.maximum(_MINIMUM_COUNT, tn + fp)
      data = {
          "tp": tp.astype(int).tolist(),
          "fp": fp.astype(int).tolist(),
          "tn": tn.astype(int).tolist(),
          "fn": fn.astype(int).tolist(),
          "tpr": tpr.astype(float).tolist(),
          "fpr": fpr.astype(float).tolist(),
      }
      return data
  
imports: import numpy
  from PIL import Image
  from visualdl.proto.record_pb2 import Record
label_desc: Use image node_id 17 for calling a global function with example usage: compute_roc_curve(labels, predictions, num_thresholds, weights) and returns: data