code: def generate_ours_offline(
      keep,
      scores,
      check_keep,
      check_scores,
      in_size=100000,
      out_size=100000,
      fix_variance=False,
  ):
      """
      Fit a single predictive model using keep and scores in order to predict
      if the examples in check_scores were training data or not, using the
      ground truth answer from check_keep.
      """
      dat_in = []
      dat_out = []
  
      for j in range(scores.shape[1]):
          dat_in.append(scores[keep[:, j], j, :])
          dat_out.append(scores[~keep[:, j], j, :])
  
      out_size = min(min(map(len, dat_out)), out_size)
  
      dat_out = np.array([x[:out_size] for x in dat_out])
  
      mean_out = np.median(dat_out, 1)
  
      if fix_variance:
          std_out = np.std(dat_out)
      else:
          std_out = np.std(dat_out, 1)
  
      prediction = []
      answers = []
      for ans, sc in zip(check_keep, check_scores):
          score = scipy.stats.norm.logpdf(sc, mean_out, std_out + 1e-30)
  
          prediction.extend(score.mean(1))
          answers.extend(ans)
      return prediction, answers
  
file_path: privacy/research/mi_lira_2021/plot.py
imports: import os
  import scipy.stats
  import numpy
  import matplotlib.pyplot
  from sklearn.metrics import auc, roc_curve
  import functools
  import matplotlib
label_desc: Use image node_id 4 for calling a global function with example usage: generate_ours_offline(keep, scores, check_keep, check_scores, in_size, out_size, fix_variance) and returns: prediction,  answers