code: def main() -> None:
      args = get_arg_parser().parse_args()
  
      processed_folder = Path(args.processed_wikidata)
      benchmark_folder = Path(args.benchmark_folder)
  
      # Get qid2alias mapping
      aliases_fpath = benchmark_folder / "aliases.jsonl"
      print(f"Loading aliases from {aliases_fpath}.")
      qid2alias = defaultdict(list)
      for item in jsonl_generator(str(aliases_fpath)):
          qid = item["qid"]
          alias = item["alias"]
          qid2alias[qid].append(alias)
      print(f"Built alias map for {len(qid2alias)} qids.")
  
      # Set of QIDs with Wikipedia pages
      print("Loading Wikipedia table.")
      wikipedia_qids = set()
      table_files = get_batch_files(
          processed_folder / args.wikipedia_links_folder
      )
      for f in tqdm(table_files, disable=None):
          with open(f) as in_file:
              for line in in_file:
                  item = json.loads(line)
                  wikipedia_qids.add(item["qid"])
      print(f"Found {len(wikipedia_qids)} QIDs with Wikpedia pages.")
  
      # load triples with seed relations
      triples_file = benchmark_folder / "triples.jsonl"
      print(
          f"Loading triples from {triples_file}. Filtering based on alias quality..."
      )
      filtered_triples = []
      for triple in tqdm(
          jsonl_generator(str(triples_file)),
          total=215288006,
          disable=None,
      ):
          q1 = triple["qid"]
          q2 = triple["value"]
          if bad_alias(qid2alias[q1]) or bad_alias(qid2alias[q2]):
              continue
          if q1 not in wikipedia_qids:
              continue
          if q2 not in wikipedia_qids:
              continue
          filtered_triples.append(triple)
  
      print(f"{len(filtered_triples)} triples after filtering.")
  
      # save to file
      filtered_triples_file = (
          benchmark_folder / "filtered_triples.jsonl"
      )
      save_jsonl(filtered_triples_file, filtered_triples)
      print(f"Saved filtered triples to {filtered_triples_file}.")
  
file_path: H2O/h2o_hf/helm/scripts/fact_completion/filter_triples.py
imports: import argparse
  from collections import defaultdict
  import json
  from tqdm import tqdm
  from pathlib import Path
  from utils import get_batch_files, jsonl_generator, save_jsonl
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types