def make_splits(questions_file, visual_genome_file, karpathy_splits):
  r"""Make train, validation, and test splits.

  The following rules are used:
    train = (karpathy_train U v7w_train) \ (karpathy_val U karpathy_test)
    val = (karpathy_val U v7w_val) \ (train U karpathy_test)
    test = (karpathy_test U v7w_test) \ (train U val)

  Args:
    questions_file: JSON file containing V7W questions.
    visual_genome_file: File containing mapping from genome ids to COCO ids.
    karpathy_splits: Train, val, and test ids for the Karpathy COCO splits.

  Returns:
    splits: Dictionary of new train, val, and test splits for V7W.
  """
  # Load mapping from visual genome ids to coco ids.
  mapping = {}
  with tf.io.gfile.GFile(visual_genome_file, "r") as f:
    metadata = json.load(f)
    for image in metadata:
      mapping[image["image_id"]] = image["coco_id"]

  # Load v7w data.
  with tf.io.gfile.GFile(questions_file, "r") as f:
    data = json.load(f)["images"]

  # Create splits.
  splits = dict(train=set(), val=set(), test=set())
  for image in data:
    v7w_split = image["split"]
    image_id = image["image_id"]
    coco_id = mapping.get(image_id)

    if coco_id in karpathy_splits["train"]:
      splits["train"].add(image_id)
    elif coco_id in karpathy_splits["val"]:
      splits["val"].add(image_id)
    elif coco_id in karpathy_splits["test"]:
      splits["test"].add(image_id)
    elif v7w_split == "train":
      splits["train"].add(image_id)
    elif v7w_split == "val":
      splits["val"].add(image_id)
    else:
      splits["test"].add(image_id)

  return splits
Make train, validation, and test splits.

  The following rules are used:
    train = (karpathy_train U v7w_train) \ (karpathy_val U karpathy_test)
    val = (karpathy_val U v7w_val) \ (train U karpathy_test)
    test = (karpathy_test U v7w_test) \ (train U val)

  Args:
    questions_file: JSON file containing V7W questions.
    visual_genome_file: File containing mapping from genome ids to COCO ids.
    karpathy_splits: Train, val, and test ids for the Karpathy COCO splits.

  Returns:
    splits: Dictionary of new train, val, and test splits for V7W.
  
language/capwap/preprocessing/v7w_qa.py