code: def get_thresholds(
      t: np.ndarray, num_samples=1000, reverse=False, opt=True
  ):
      if opt:
          # use the worst-case for efficient determination of thresholds
          max_idx = t.reshape(t.shape[0], -1).max(1).argmax(0)
          t = t[max_idx].flatten()
          # return [kthvalue(t, max(1, math.floor(t.size * i / num_samples)-1)-1)
          #            for i in range(num_samples, 0, -1)]
          r = np.linspace(0, t.size - 1, num=num_samples).astype(int)
          if reverse:
              r = r[::-1]
          t.sort()
          return t[r]
          # idx = np.argsort(t)
          # return [t[idx[max(1, math.floor(t.size * i / num_samples)-1)-1]] for i in range(num_samples, 0, -1)]
      else:
          # return [kthvalue(t.flatten(), max(1, math.floor(t.size * i / num_samples)))
          #            for i in range(num_samples, 0, -1)]
  
          r = np.linspace(t.min(), t.max(), num=num_samples)
          if reverse:
              r = r[::-1]
          return r
  
imports: import os
  import argparse
  import numpy
  import matplotlib
  import matplotlib.pyplot
  from sklearn.metrics import roc_curve, auc
  from tqdm import tqdm
  from skimage import measure, morphology
  from skimage.segmentation import mark_boundaries
  import paddle
label_desc: Use image node_id 11 for calling a global function with example usage: get_thresholds(t, num_samples, reverse, opt) and returns: t, r