code: def flip_labels(samples, N):
      flip_cnt = 0
      for sample in samples:
          text = sample["text"]
          flip = hashlib.md5(text.encode("utf8")).digest()[0] < N * 256
          labels = sample["labels"]
          # deterministic flipping for each example
          if flip:
              flip_cnt += 1
              if labels[0] == "__ok__":
                  new_labels = ["__notok__"]
              elif labels[0] == "__notok__":
                  new_labels = ["__ok__"]
              else:
                  raise ValueError(
                      "labels are not in the right format."
                  )
          if flip:
              sample["labels"] = new_labels
      logging.debug(f"{flip_cnt} labels flipped.")
      return samples
  
file_path: ParlAI/parlai/tasks/safety_mix/build.py
imports: import copy
  import hashlib
  import json
  import os
  import random
  import numpy
  import parlai.core.build_data
  import parlai.utils.logging
  from parlai.core.build_data import DownloadableFile
label_desc: Use image node_id 2 for calling a global function with example usage: flip_labels(samples, N) and returns: samples