code: def plot_roc_and_calculate_tpr(scores, names=None, label=None):
      print(">>>> plot roc and calculate tpr...")
      score_dict = {}
      for id, score in enumerate(scores):
          name = None if names is None else names[id]
          if isinstance(score, str) and score.endswith(".npz"):
              aa = np.load(score)
              score = aa.get("scores", [])
              label = (
                  aa["label"]
                  if label is None and "label" in aa
                  else label
              )
              score_name = aa.get("names", [])
              for ss, nn in zip(score, score_name):
                  score_dict[nn] = ss
          elif isinstance(score, str) and score.endswith(".npy"):
              name = (
                  name
                  if name is not None
                  else os.path.splitext(os.path.basename(score))[0]
              )
              score_dict[name] = np.load(score)
          elif isinstance(score, str) and score.endswith(".txt"):
              # IJB meta data like ijbb_template_pair_label.txt
              label = pd.read_csv(score, sep=" ", header=None).values[
                  :, 2
              ]
          else:
              name = name if name is not None else str(id)
              score_dict[name] = score
      if label is None:
          print("Error: Label data is not provided")
          return None, None
  
      x_labels = [10 ** (-ii) for ii in range(1, 7)[::-1]]
      fpr_dict, tpr_dict, roc_auc_dict, tpr_result = {}, {}, {}, {}
      for name, score in score_dict.items():
          fpr, tpr, _ = roc_curve(label, score)
          roc_auc = auc(fpr, tpr)
          fpr, tpr = np.flipud(fpr), np.flipud(
              tpr
          )  # select largest tpr at same fpr
          tpr_result[name] = [
              tpr[np.argmin(abs(fpr - ii))] for ii in x_labels
          ]
          fpr_dict[name], tpr_dict[name], roc_auc_dict[name] = (
              fpr,
              tpr,
              roc_auc,
          )
      tpr_result_df = pd.DataFrame(tpr_result, index=x_labels).T
      tpr_result_df["AUC"] = pd.Series(roc_auc_dict)
      tpr_result_df.columns.name = "Methods"
      print(tpr_result_df.to_markdown())
      # print(tpr_result_df)
  
      try:
          import matplotlib.pyplot as plt
  
          fig = plt.figure()
          for name in score_dict:
              plt.plot(
                  fpr_dict[name],
                  tpr_dict[name],
                  lw=1,
                  label="[%s (AUC = %0.4f%%)]"
                  % (name, roc_auc_dict[name] * 100),
              )
          title = (
              "ROC on IJB" + name.split("IJB")[-1][0]
              if "IJB" in name
              else "ROC on IJB"
          )
  
          plt.xlim([10**-6, 0.1])
          plt.xscale("log")
          plt.xticks(x_labels)
          plt.xlabel("False Positive Rate")
          plt.ylim([0.3, 1.0])
          plt.yticks(np.linspace(0.3, 1.0, 8, endpoint=True))
          plt.ylabel("True Positive Rate")
  
          plt.grid(linestyle="--", linewidth=1)
          plt.title(title)
          plt.legend(loc="lower right", fontsize="x-small")
          plt.tight_layout()
          plt.show()
      except:
          print("matplotlib plot failed")
          fig = None
  
      return tpr_result_df, fig
  
imports: import os
  import cv2
  import numpy
  import pandas
  from tqdm import tqdm
  from skimage import transform
  from sklearn.preprocessing import normalize
  from sklearn.metrics import roc_curve, auc
label_desc: Use image node_id 11 for calling a global function with example usage: plot_roc_and_calculate_tpr(scores, names, label) and returns: tpr_result_df,  fig, None,  None